https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225584
--- Comment #59 from Konstantin Belousov <k...@freebsd.org> --- (In reply to mike from comment #58) Lets try a slight variation. diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index 069ed64c4e9..935bf18b529 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/atomic.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,14 @@ void _funlockfile(FILE *fp) { pthread_t curthread = _pthread_self(); + pthread_t fl_owner; /* * Check if this file is owned by the current thread: */ - if (fp->_fl_owner == curthread) { + while ((fl_owner = (pthread_t)atomic_load_ptr(&fp->_fl_owner)) == NULL) + ; + if (fl_owner == curthread) { /* * Check if this thread has locked the FILE * more than once: @@ -138,4 +145,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, fl_owner, fp->_fl_owner); + write(2, x, strlen(x)); + raise(SIGBUS); + } } -- You are receiving this mail because: You are the assignee for the bug. _______________________________________________ freebsd-bugs@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"