Bug 44668 - backtrace_symbols() reports wrong function names
backtrace_symbols() reports wrong function names
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-15 04:14 EDT by Martin Strassburger
Modified: 2007-04-18 12:33 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-06-15 04:14:37 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Martin Strassburger 2001-06-15 04:14:34 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i686)

Description of problem:
In our software product the function backtrace_symbols() is used in signal
handlers to find out where some error raised.
In glibc 2.2.2 the output of backtrace_symbols() and backtrace_symbols_fd()
seems to be broken.

How reproducible:
Always

Steps to Reproduce:
1. compile the following coding and execute it
#include <execinfo.h>
void showStack()
{
  void * array [1024];
  backtrace_symbols_fd(array, 
		       backtrace(array, sizeof(array)/sizeof(array[0])),
		       1);
}

void b()
{
  showStack();
}

void a()
{
  b();
}

int main()
{
  a();
  return 0;
}

2. The output looks like this:
./a.out(backtrace_symbols_fd+0x133)[0x80484df]
./a.out(backtrace_symbols_fd+0x157)[0x8048503]
./a.out(backtrace_symbols_fd+0x167)[0x8048513]
./a.out(backtrace_symbols_fd+0x177)[0x8048523]
/lib/i686/libc.so.6(__libc_start_main+0x93)[0x40041177]
./a.out(backtrace_symbols_fd+0x35)[0x80483e1]

3. The output should look like this:
./a.out(showStack+0x??)[0x80484df]
./a.out(b+0x??)[0x8048503]
./a.out(a+0x??)[0x8048513]
./a.out(main+0x??)[0x8048523]
/lib/i686/libc.so.6(__libc_start_main+0x93)[0x40041177]

It's really a pity not to get the function names because it makes debugging
of large programs much easier.
Comment 1 Jakub Jelinek 2001-06-15 06:35:49 EDT
backtrace_symbols does not use debugging info nor symbol table, that's
what debuggers are for.
backtrace_symbols uses information from the dynamic symbol table, so if
a function is not in dynamic symbol table, it cannot show up in the backtrace
listing. Unless you play with symbol versioning or symbol visibility, all
non-static functions make it into the dynamic symbol table for shared libraries,
for binaries you have to request that explicitely.
-Wl,--export-dynamic will do the job (tested on your example).

Note You need to log in before you can comment on or make changes to this bug.