backtrace_symbols() on aarch64 device returns empty on SIGSEGV

115 Views Asked by At

I was trying to get backtrace in signal handler. The simple code from manpage worked on armv7 inside a signal handler. But I was unable to run the same code on an aarch64. Compiled with the -rdynamic -funwind-tables -no-pie flags for both platforms (also tried -g).

backtrace() returns non zero. But when I try to iterate over "strings" to print (or write to file) them I get a segfault. Also tried the backtrace_symbols_fd() alternative, this doesn't result in segfault but the output file remains empty. (All of these work on armv7)

    int nptrs;
    void *buffer[BT_BUF_SIZE];
    char **strings;
    nptrs = backtrace(buffer, BT_BUF_SIZE);
    printf("backtrace() returned %d addresses\n", nptrs);

    strings = backtrace_symbols(buffer, nptrs);
    if (strings == NULL) {
        perror("backtrace_symbols");
        exit(EXIT_FAILURE);
    }

I compared glibc versions, same on both devices. Where should I be looking for the problem? I don't want to go for solutions like using uclibc or libunwind?

0

There are 0 best solutions below