Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 09 Feb 2018 14:33:39 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 225584] Various compile process hang on Ryzen, but not on Intel
Message-ID:  <bug-225584-8-XxgzkrNLMP@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-225584-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-225584-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=3D225584

--- Comment #69 from Konstantin Belousov <kib@FreeBSD.org> ---
(In reply to mike from comment #68)
Please try this, it should work and then it would be the last thing I am as=
king
to test.

diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c
index 069ed64c4e9..816e958b1f0 100644
--- a/lib/libc/stdio/_flock_stub.c
+++ b/lib/libc/stdio/_flock_stub.c
@@ -39,12 +39,16 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

+#include <sys/types.h>
+#include <machine/cpufunc.h>
 #include "namespace.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
 #include "un-namespace.h"
+#include <signal.h>
+#include <unistd.h>

 #include "local.h"

@@ -112,11 +116,17 @@ void
 _funlockfile(FILE *fp)
 {
        pthread_t       curthread =3D _pthread_self();
+       pthread_t owner;

        /*
         * Check if this file is owned by the current thread:
         */
-       if (fp->_fl_owner =3D=3D curthread) {
+       owner =3D fp->_fl_owner;
+       if (owner =3D=3D NULL) {
+               mfence();
+               owner =3D fp->_fl_owner;
+       }
+       if (owner =3D=3D curthread) {
                /*
                 * Check if this thread has locked the FILE
                 * more than once:
@@ -138,4 +148,11 @@ _funlockfile(FILE *fp)
                        _pthread_mutex_unlock(&fp->_fl_mutex);
                }
        }
+       else {
+               char x[120];
+               snprintf(x, sizeof(x), "funlockfile %p %p %p %p\n", fp,
+                   curthread, owner, fp->_fl_owner);
+               write(2, x, strlen(x));
+               raise(SIGBUS);
+       }
 }

--=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-225584-8-XxgzkrNLMP>