Bug#605611: libc: backtrace_symbols wrong when in unexpected_handler
Package: libc6
Version: 2.11.2-7
Severity: normal
File: libc
Tags: upstream
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
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-5-686-bigmem (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libc6 depends on:
ii libc-bin 2.11.2-7 Embedded GNU C Library: Binaries
ii libgcc1 1:4.4.5-6 GCC support library
Versions of packages libc6 recommends:
ii libc6-i686 2.11.2-7 Embedded GNU C Library: Shared lib
Versions of packages libc6 suggests:
ii debconf [debconf-2.0] 1.5.36 Debian configuration management sy
pn glibc-doc <none> (no description available)
ii locales 2.11.2-7 Embedded GNU C Library: National L
-- debconf information excluded
Reply to: