From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3284 invoked by alias); 9 Jan 2013 13:45:06 -0000 Received: (qmail 1555 invoked by uid 48); 9 Jan 2013 13:44:05 -0000 From: "tobias at ringis dot se" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55918] New: Stack partially unwound when noexcept causes call to std::terminate Date: Wed, 09 Jan 2013 13:45:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tobias at ringis dot se X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00794.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55918 Bug #: 55918 Summary: Stack partially unwound when noexcept causes call to std::terminate Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: tobias@ringis.se Created attachment 29123 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29123 Test program to illustrate the problem When a noexcept function is "violated", std::terminate is called. While the standard allows for the stack to be fully unwound, partially unwound, or not unwound at all, it is impossible to find the location where the exception was thrown, unless the stack is left unwound. GCC currently leaves the stack unwound in most cases, but in a very common case, which is illustrated by the attached example program, the stack is partially unwound. If the noexcept is removed to allow the exception to propagate all the way past main, std::terminate is called with the stack fully unwound, so it seems that GCC is able to do what I want. It would be highly desirable for the noexcept case to work in the same way as the unhandled exception case. # g++ -std=c++0x -g tmp3.cpp # gdb a.out [...] (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 0x00000031964b8e49 in ?? () from /usr/lib64/libstdc++.so.6 #5 0x00000031964b973d in __gxx_personality_v0 () from /usr/lib64/libstdc++.so.6 #6 0x000000319000f6fb in ?? () from /lib64/libgcc_s.so.1 #7 0x000000319000fb58 in _Unwind_Resume () from /lib64/libgcc_s.so.1 #8 0x0000000000400911 in level2 () at tmp3.cpp:16 #9 0x000000000040091a in level1 () at tmp3.cpp:20 #10 0x0000000000400925 in main () at tmp3.cpp:24 As you can see, bad_guy is not in the backtrace. There are two simple modifications that makes the backtrace complete. The first is to remove the noexcept from level1, and the second is to remove the Foo declaration in level2 (or delete Foo's destructor).