[Bug libstdc++/96817] __cxa_guard_acquire unsafe against dynamically loaded pthread

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Aug 27 14:04:56 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96817

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh plus this for the aborted init case:

@@ -351,7 +366,17 @@ namespace __cxxabiv1
 #ifdef _GLIBCXX_USE_FUTEX
     // If __atomic_* and futex syscall are supported, don't use any global
     // mutex.
+#if __has_include(<sys/single_threaded.h>)
+    // Prefer to rely on __libc_single_threaded instead of __gthread_active_p
+    if (__libc_single_threaded)
+      {
+       int *gi = (int *) (void *) g;
+       *gi = 0;
+       return;
+      }
+#else
     if (__gthread_active_p ())
+#endif
       {
        int *gi = (int *) (void *) g;
        const int waiting_bit = _GLIBCXX_GUARD_WAITING_BIT;


More information about the Gcc-bugs mailing list