Bug 44668 - backtrace_symbols() reports wrong function names
Summary: backtrace_symbols() reports wrong function names
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Aaron Brown
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-06-15 08:14 UTC by Martin Strassburger
Modified: 2016-11-24 15:09 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-06-15 08:14:37 UTC
Embargoed:


Attachments (Terms of Use)

Description Martin Strassburger 2001-06-15 08:14:34 UTC
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 10:35:49 UTC
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.