On FreeBSD 11.0, the POSIX testdir produces a crash of the test-pthread_sigmask2
test. It crashes right at the first call to pthread_sigmask:

   ASSERT (pthread_sigmask (1729, &set, NULL) == EINVAL);

The reason is that pthread_sigmask is #defined to rpl_pthread_sigmask
and rpl_pthread_sigmask is defined as a weak symbol

  $ nm test-pthread_sigmask2.o | grep pthread_sigmask
                   w rpl_pthread_sigmask

because test-pthread_sigmask2.c happens to include first <signal.h> and then
glthread/thread.h.

This patch fixes it (and makes sure that when pthread_sigmask is needed by
the 'thread' module, we get the right one).


2017-08-16  Bruno Haible  <[email protected]>

        thread: Fix conflict with pthread_sigmask module.
        * lib/glthread/thread.h (pthread_sigmask): Don't declare it weak if
        it's defined as a macro.
        * modules/thread (Depends-on): Add pthread_sigmask.

diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h
index 72bdd9b..52336c6 100644
--- a/lib/glthread/thread.h
+++ b/lib/glthread/thread.h
@@ -128,7 +128,9 @@ extern int glthread_in_use (void);
   /* Without this, clang complains that pthread_sigmask is never declared.  */
 #   include <signal.h>
 #  endif
-#  pragma weak pthread_sigmask
+#  ifndef pthread_sigmask /* Do not declare rpl_pthread_sigmask weak.  */
+#   pragma weak pthread_sigmask
+#  endif
 
 #  pragma weak pthread_join
 #  ifndef pthread_self
diff --git a/modules/thread b/modules/thread
index 026e439..b4e9d78 100644
--- a/modules/thread
+++ b/modules/thread
@@ -10,6 +10,7 @@ Depends-on:
 threadlib
 extern-inline
 lock
+pthread_sigmask [test $gl_threads_api = posix]
 
 configure.ac:
 gl_THREAD


Reply via email to