public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/55917] New: Impossible to find/debug unhandled exceptions in an std::thread
@ 2013-01-09 13:21 tobias at ringis dot se
  2013-01-09 13:23 ` [Bug libstdc++/55917] " tobias at ringis dot se
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: tobias at ringis dot se @ 2013-01-09 13:21 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55917

             Bug #: 55917
           Summary: Impossible to find/debug unhandled exceptions in an
                    std::thread
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tobias@ringis.se


If an unhandled exception occurs in an std::thread, the stack is unwound before
std::terminate is called, which makes it impossible to find the location of the
exception.

I emailed gcc-help about this about a year ago, and learned that a fix was
supposed to be applied for 4.7, but that fix didn't work out. Here's my post:

  http://gcc.gnu.org/ml/gcc-help/2011-11/msg00140.html

The reason for the unwound stack is that libstdc++'s function that calls the
user's thread function contains a try/catch all statement.  The supposed fix
was to use noexcept on the internal thread main function, and the reason why it
did not work out is described here:

  http://gcc.gnu.org/ml/gcc-help/2013-01/msg00068.html

I've tested 4.6, 4.7 and a 4.8 snapshot with identical results.  See the
attached test program tmp4.cpp. Compile with:

  g++ -std=c++0x -g tmp4.cpp -lpthread

Run in gdb:

~> gdb a.out
[...]
(gdb) r
Starting program: /home/tobias/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff7fd0700 (LWP 10278)]
terminate called after throwing an instance of 'std::runtime_error'
  what():  foo

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff7fd0700 (LWP 10278)]
0x000000318f036285 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install
glibc-2.14.90-24.fc16.9.x86_64 libgcc-4.6.3-2.fc16.x86_64
libstdc++-4.6.3-2.fc16.x86_64
(gdb) bt
#0  0x000000318f036285 in raise () from /lib64/libc.so.6
#1  0x000000318f037b9b in abort () from /lib64/libc.so.6
#2  0x00000031964bbc5d in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib64/libstdc++.so.6
#3  0x00000031964b9e16 in ?? () from /usr/lib64/libstdc++.so.6
#4  0x00000031964b9e43 in std::terminate() () from /usr/lib64/libstdc++.so.6
#5  0x0000003196470b0b in ?? () from /usr/lib64/libstdc++.so.6
#6  0x000000318fc07d90 in start_thread () from /lib64/libpthread.so.0
#7  0x000000318f0f119d in clone () from /lib64/libc.so.6
(gdb) 

As you can see, neither the thread's main function, nor foo() is in the
backtrace.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-11-24 14:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-09 13:21 [Bug libstdc++/55917] New: Impossible to find/debug unhandled exceptions in an std::thread tobias at ringis dot se
2013-01-09 13:23 ` [Bug libstdc++/55917] " tobias at ringis dot se
2013-01-09 13:45 ` redi at gcc dot gnu.org
2013-01-09 13:48 ` redi at gcc dot gnu.org
2013-01-09 14:00 ` redi at gcc dot gnu.org
2013-01-09 14:06 ` tobias at ringis dot se
2013-01-09 14:42 ` redi at gcc dot gnu.org
2013-07-02 10:30 ` yuri.aksenov at gmail dot com
2013-07-02 11:20 ` redi at gcc dot gnu.org
2013-07-02 11:26 ` redi at gcc dot gnu.org
2013-07-02 12:05 ` yuri.aksenov at gmail dot com
2013-07-02 12:27 ` yuri.aksenov at gmail dot com
2013-07-02 15:46 ` redi at gcc dot gnu.org
2014-11-24 14:53 ` rogero at howzatt dot demon.co.uk

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).