[Bug libstdc++/60662] simple use of call_once throws a system_error exception, but not if sleep_for is called beforehand

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 23 14:00:29 GMT 2020


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED
   Target Milestone|---                         |11.0

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I am able to reproduce this on Ubuntu 13.10, and it can be fixed by using
-Wl,--no-as-needed before -lpthread which ensures the executable is linked to
libpthread.so even though the linker thinks it's not needed.

I'm not sure why this_thread::sleep_for (which just calls nanosleep) causes
libpthread.so to get linked in, but ldd shows that there is a libpthread.so
dependency with it.

This should be fixed in GCC 11 which no longer uses pthread_once for
std::call_once.


More information about the Gcc-bugs mailing list