[Bug libstdc++/57975] Core dump caused by linking with -lpthread
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 24 23:30:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It only "works" without -lpthread because the implementation of
pthread_mutex_lock() in libc.so is a no-op, so your program is a busy loop that
spins using 100% CPU, not waiting patiently on the condvar.
When you link to libpthread you get a real implementation of pthread_mutex_lock
that fails because when you call condvar.wait(lock) you fail to meet the
precondition that lock.owns_lock() is true, so it's undefined behaviour.
More information about the Gcc-bugs
mailing list