public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/46751] New: backtrace_symbols wrong when in unexpected_handler
@ 2010-12-01 19:13 erik at cq2 dot nl
2010-12-01 19:18 ` [Bug libstdc++/46751] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: erik at cq2 dot nl @ 2010-12-01 19:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46751
Summary: backtrace_symbols wrong when in unexpected_handler
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: erik@cq2.nl
When in an std::unexpected_handler, backtrace_symbols returns a trace with
functions not even called at all.
I noticed strange functions to appear on the trace, and missed functions that
should be there.
I reproduced it with the following minimal code:
#include <exception>
#include <execinfo.h>
extern "C" void my_unexpected_handler() {
void* trace[100];
int size = backtrace(trace, 100);
backtrace_symbols_fd(trace, size, 2);
}
void throw_0() throw() {
throw 0;
}
extern "C" void not_called_at_all_but_appearing_on_the_backtrace() { }
extern "C" int main(int, char*[]) {
std::set_unexpected(my_unexpected_handler);
throw_0();
return 0;
}
I compile this with: g++ -g -rdynamic <filename>
It then produces:
./a.out(my_unexpected_handler+0x1f)[0x8048973]
/usr/lib/libstdc++.so.6(+0xbd465)[0xb7853465]
/usr/lib/libstdc++.so.6(__cxa_call_unexpected+0x45)[0xb78528b5]
./a.out(not_called_at_all_but_appearing_on_the_backtrace+0x0)[0x80489dc]
./a.out(main+0x1a)[0x80489fb]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7621c76]
./a.out[0x80488c1]
terminate called after throwing an instance of 'int'
Aborted
As you can see, "not_called_at_all_but_appearing_on_the_backtrace" is not
called anywhere, but yet it is on the stack trace.
The function throw_0 however is missing.
I believe this is a bug. If not, what is going on here?
Best regards
Erik Groeneveld
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/46751] backtrace_symbols wrong when in unexpected_handler
2010-12-01 19:13 [Bug libstdc++/46751] New: backtrace_symbols wrong when in unexpected_handler erik at cq2 dot nl
@ 2010-12-01 19:18 ` pinskia at gcc dot gnu.org
2010-12-01 19:27 ` erik at cq2 dot nl
2012-02-04 0:25 ` [Bug middle-end/46751] " pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-12-01 19:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46751
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-12-01 19:18:02 UTC ---
backtrace is part of libc and not GCC.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/46751] backtrace_symbols wrong when in unexpected_handler
2010-12-01 19:13 [Bug libstdc++/46751] New: backtrace_symbols wrong when in unexpected_handler erik at cq2 dot nl
2010-12-01 19:18 ` [Bug libstdc++/46751] " pinskia at gcc dot gnu.org
@ 2010-12-01 19:27 ` erik at cq2 dot nl
2012-02-04 0:25 ` [Bug middle-end/46751] " pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: erik at cq2 dot nl @ 2010-12-01 19:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46751
--- Comment #2 from Erik J Groeneveld <erik at cq2 dot nl> 2010-12-01 19:27:26 UTC ---
(In reply to comment #1)
> backtrace is part of libc and not GCC.
Thank you, I'll post it there too.
Could it also have to do something with exception handling code in the c++
runtime that calls unexpected_handler? I think it somehow leaves the stack in
a state that backtrace does not expect. That still leaves open the question
where the bug is, if any.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/46751] backtrace_symbols wrong when in unexpected_handler
2010-12-01 19:13 [Bug libstdc++/46751] New: backtrace_symbols wrong when in unexpected_handler erik at cq2 dot nl
2010-12-01 19:18 ` [Bug libstdc++/46751] " pinskia at gcc dot gnu.org
2010-12-01 19:27 ` erik at cq2 dot nl
@ 2012-02-04 0:25 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-04 0:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46751
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|libstdc++ |middle-end
Resolution| |INVALID
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-04 00:25:04 UTC ---
The backtrace is mostly right. The issue is that the function after
_Z7throw_0v is not_called_at_all_but_appearing_on_the_backtrace.
The debugging info is correct. The call return place is really
not_called_at_all_but_appearing_on_the_backtrace.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-04 0:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 19:13 [Bug libstdc++/46751] New: backtrace_symbols wrong when in unexpected_handler erik at cq2 dot nl
2010-12-01 19:18 ` [Bug libstdc++/46751] " pinskia at gcc dot gnu.org
2010-12-01 19:27 ` erik at cq2 dot nl
2012-02-04 0:25 ` [Bug middle-end/46751] " pinskia at gcc dot gnu.org
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).