public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57975] New: Core dump caused by linking with -lpthread
@ 2013-07-24 22:37 michi at triodia dot com
2013-07-24 22:38 ` [Bug c++/57975] " michi at triodia dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: michi at triodia dot com @ 2013-07-24 22:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
Bug ID: 57975
Summary: Core dump caused by linking with -lpthread
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: michi at triodia dot com
The following code works as expected when compiling with
c++ -g --std=c++11 test.cpp
The program hangs until it is interrupted.
When I compile the same code with
c++ -g --std=c++11 test.cpp -lpthread
I get a segfault in wait():
Program received signal SIGSEGV, Segmentation fault.
__pthread_mutex_unlock_usercnt (mutex=0x0, decr=0) at pthread_mutex_unlock.c:37
37 pthread_mutex_unlock.c: No such file or directory.
(gdb) bt
#0 __pthread_mutex_unlock_usercnt (mutex=0x0, decr=0) at
pthread_mutex_unlock.c:37
#1 0x00007ffff7bc8c17 in pthread_cond_wait@@GLIBC_2.3.2 ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:94
#2 0x00007ffff79698ec in
std::condition_variable::wait(std::unique_lock<std::mutex>&) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x0000000000400a69 in main () at test.cpp:13
Here is the complete source:
#include <condition_variable>
#include <mutex>
int main(int, char**)
{
bool predicate = false;
std::mutex mutex;
std::condition_variable condvar;
std::unique_lock<decltype(mutex)> lock;
while (!predicate)
{
condvar.wait(lock);
}
}
Compiler version is
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
running on Ubuntu Raring.
libpthread is:
libpthread.so.0 (libc6,x86-64, OS ABI: Linux 2.6.24) =>
/lib/x86_64-linux-gnu/libpthread.so.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
@ 2013-07-24 22:38 ` michi at triodia dot com
2013-07-24 23:07 ` paolo.carlini at oracle dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: michi at triodia dot com @ 2013-07-24 22:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
Michi Henning <michi at triodia dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|unknown |4.7.3
--- Comment #1 from Michi Henning <michi at triodia dot com> ---
uname reports:
Linux ubuntu 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:35:23 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
2013-07-24 22:38 ` [Bug c++/57975] " michi at triodia dot com
@ 2013-07-24 23:07 ` paolo.carlini at oracle dot com
2013-07-24 23:23 ` [Bug libstdc++/57975] " redi at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-24 23:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|michi at triodia dot com |jwakely.gcc at gmail dot com
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Jon, can you help me with this?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
2013-07-24 22:38 ` [Bug c++/57975] " michi at triodia dot com
2013-07-24 23:07 ` paolo.carlini at oracle dot com
@ 2013-07-24 23:23 ` redi at gcc dot gnu.org
2013-07-24 23:30 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-07-24 23:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-07-24
Component|c++ |libstdc++
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
` (2 preceding siblings ...)
2013-07-24 23:23 ` [Bug libstdc++/57975] " redi at gcc dot gnu.org
@ 2013-07-24 23:30 ` redi at gcc dot gnu.org
2013-07-24 23:36 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-07-24 23:30 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
` (3 preceding siblings ...)
2013-07-24 23:30 ` redi at gcc dot gnu.org
@ 2013-07-24 23:36 ` paolo.carlini at oracle dot com
2013-07-24 23:37 ` redi at gcc dot gnu.org
2013-07-25 0:25 ` michi at triodia dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-24 23:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
` (4 preceding siblings ...)
2013-07-24 23:36 ` paolo.carlini at oracle dot com
@ 2013-07-24 23:37 ` redi at gcc dot gnu.org
2013-07-25 0:25 ` michi at triodia dot com
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-07-24 23:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I am working (slowly) on some additional Debug Mode checks in <mutex>,
<condition_variable> etc. so at some point you'll be able to debug this with
-D_GLIBCX_DEBUG
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/57975] Core dump caused by linking with -lpthread
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
` (5 preceding siblings ...)
2013-07-24 23:37 ` redi at gcc dot gnu.org
@ 2013-07-25 0:25 ` michi at triodia dot com
6 siblings, 0 replies; 8+ messages in thread
From: michi at triodia dot com @ 2013-07-25 0:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975
--- Comment #6 from Michi Henning <michi at triodia dot com> ---
How embarrassing. The joys of default constructors :-( Stupid mistake of mine.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-07-25 0:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-24 22:37 [Bug c++/57975] New: Core dump caused by linking with -lpthread michi at triodia dot com
2013-07-24 22:38 ` [Bug c++/57975] " michi at triodia dot com
2013-07-24 23:07 ` paolo.carlini at oracle dot com
2013-07-24 23:23 ` [Bug libstdc++/57975] " redi at gcc dot gnu.org
2013-07-24 23:30 ` redi at gcc dot gnu.org
2013-07-24 23:36 ` paolo.carlini at oracle dot com
2013-07-24 23:37 ` redi at gcc dot gnu.org
2013-07-25 0:25 ` michi at triodia dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).