Aurelien Jarno wrote:
Bartek 'BaSz' Szurgot a écrit :


some time ago i wrote C++ code to save backtrace in a vector of strings. it worked fine until one of system updates (~month ago), when it suddenly started to show too short listening(s). i've tried example from manual (man backtrace) to verify this, and it does not work properly too. example output is:

$ gcc -Wall -g3 -rdynamic main.c && ./a.out 10
backtrace() returned 4 addresses
./a.out(_Z7myfunc3v+0x1c) [0x400b28]
./a.out [0x400ba9]
./a.out(_Z6myfunci+0x23) [0x400bce]
./a.out(_Z6myfunci+0x1c) [0x400bc7]

where there should be >10 calls on stack. raising number given as an argument does not change output.

What are the missing entries you expect?

in the man's example function myFunc() is recurrent. here it should be
call 10 times. this is its body taken from man:
void myfunc(int ncalls)
  if (ncalls > 1)
    myfunc(ncalls - 1);

example output provided in man does show more calls to myFunc() (i.e. 3):

$ cc -rdynamic prog.c -o prog
$ ./prog 3
backtrace() returned 8 addresses
./prog(myfunc3+0x5c) [0x80487f0]
./prog [0x8048871]
./prog(myfunc+0x21) [0x8048894]
./prog(myfunc+0x1a) [0x804888d]
./prog(myfunc+0x1a) [0x804888d]
./prog(main+0x65) [0x80488fb]
/lib/ [0xb7e38f9c]
./prog [0x8048711]

do you know what can be the reason for problems with backtrace? it looks like glibc problem, since before system upgrade (~month ago, but i may not be very accurate here) everything worked as a charm.

Have you tried to install libc6-dbg and libstdc++6-4.3-dbg?

no - i haven't. do you expect it to work or do you need a gdb's
backtrace from backtrace()/backtrace_system() call?

i've attached man's example to this @. can you check does this work on
your machine?

btw: all machines i've tested this issue on so far were x86_64.

pozdrawiam serdecznie / best regards,
Bartek 'BaSz' Szurgot

Wroclaw Centre for Networking and Supercomputing
Wroclaw University of Technology,
pl. Grunwaldzki 9, D2/101,
50-377 Wroclaw
// gcc -Wall -g3 -rdynamic main.c && ./a.out 10

#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void myfunc3(void)
  int j, nptrs;
#define SIZE 100
  void *buffer[100];
  char **strings;

  nptrs = backtrace(buffer, SIZE);
  printf("backtrace() returned %d addresses\n", nptrs);

  /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
     would produce similar output to the following: */

  strings = backtrace_symbols(buffer, nptrs);
  if (strings == NULL) {

  for (j = 0; j < nptrs; j++)
    printf("%s\n", strings[j]);


static void myfunc2(void)

void myfunc(int ncalls)
  if (ncalls > 1)
    myfunc(ncalls - 1);

int main(int argc, char *argv[])
  if (argc != 2) {
    fprintf(stderr, "%s num-calls\n", argv[0]);


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to