Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jul 2017 22:26:03 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 219399] System panics after several hours of 14-threads-compilation orgies using poudriere on AMD Ryzen...
Message-ID:  <bug-219399-8-s0Dh4tw28A@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-219399-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-219399-8@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D219399

--- Comment #108 from Don Lewis <truckman@FreeBSD.org> ---
(In reply to Nils Beyer from comment #91)
I'm pretty sure that ryzen_segv_test is actually broken.  The first iterati=
on
of the loop in the t2 threadx() is unlocked and there is no guarantee that =
it
will have initialized things before thread1() tries to use them.

Try this patch:

--- ryzen_segv_test.c.orig      2017-07-24 14:26:23.851846000 -0700
+++ ryzen_segv_test.c   2017-07-24 15:02:33.998102000 -0700
@@ -291,29 +291,32 @@
        atomic_store(&flg, 0);
 }

+void threadx_core()
+{
+       uint8_t offset;
+       uint32_t randval;
+
+       offset =3D random() % 256;
+       randval =3D random();
+       memset(func_set, 0, sizeof(func_set_t));
+       memcpy(&func_set->func[offset], func_base, FUNC_BYTES);
+       func_set->offset =3D offset;
+       func_set->ret =3D randval;
+}
+
 void threadx(void *p)
 {
        uint8_t offset;
        uint32_t randval;
        int init =3D 0;
-       if(p !=3D NULL) {
-               init =3D 1;
-       }

        //usleep(1000);

        while(atomic_load(&flg)) {
                offset =3D random() % 256;
                randval =3D random();
-               if(!init) {
-                       lock_enter();
-               } else {
-                       if(func_set =3D=3D MAP_FAILED) {
-                               fprintf(stderr, "mmap returns MAP_FAILED!\n=
");
-                               return;
-                       }
-                       init =3D 0;
-               }
+               lock_enter();
+               // threadx_core();
                memset(func_set, 0, sizeof(func_set_t));
                memcpy(&func_set->func[offset], func_base, FUNC_BYTES);
                func_set->offset =3D offset;
@@ -330,8 +333,7 @@
 {
        int64_t loops;
        pthread_t t1, t2, t3;
-#ifdef _MSC_VER
-#else
+#if !defined(_MSC_VER) && !defined(__FreeBSD__)
        cpu_set_t cpuset;
        int cpu;
 #endif
@@ -349,19 +351,23 @@
        n_cpus =3D sysconf(_SC_NPROCESSORS_ONLN);
        func_set =3D mmap (NULL, sizeof(func_set_t), PROT_READ | PROT_WRITE=
 |
PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 #endif
+       if(func_set =3D=3D MAP_FAILED) {
+               fprintf(stderr, "mmap returns MAP_FAILED!\n");
+               exit (1);
+       }

        atomic_store(&flg, 1);
        atomic_store(&locked, 1);

        srandom(time(NULL) + pid);
        // You should confirm assembly of generated code, just in case the
compiler reorders mfence instruction
+       threadx_core();
        mfence(); // Assure that flags are stored properly
        pthread_create(&t1, NULL, (void*)thread1, &loops);
-       pthread_create(&t2, NULL, (void*)threadx, (void*)1);
+       pthread_create(&t2, NULL, (void*)threadx, NULL);
        pthread_create(&t3, NULL, (void*)threadx, NULL);

-#ifdef _MSC_VER
-#else
+#if !defined(_MSC_VER) && !defined(__FreeBSD__)
        cpu =3D random() % n_cpus;
        CPU_ZERO(&cpuset);
        CPU_SET(cpu, &cpuset);

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-219399-8-s0Dh4tw28A>