Bug 44668 - backtrace_symbols() reports wrong function names
backtrace_symbols() reports wrong function names
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
Depends On:
  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:
Last Closed: 2001-06-15 04:14:37 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
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:

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

void b()

void a()

int main()
  return 0;

2. The output looks like this:

3. The output should look like this:

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.