[Bug 243746] backtrace() not returning any stack frames [12.1-RELEASE-p1 amd64]

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Jan 30 22:25:27 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=243746

            Bug ID: 243746
           Summary: backtrace() not returning any stack frames
                    [12.1-RELEASE-p1 amd64]
           Product: Base System
           Version: 12.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: mandree at FreeBSD.org

*** Description
Trying to debug e2fsprogs, which uses backtrace(), I did not see stack
backtraces for a crasher.

I have then adapted a test program found on the net, which also does not find
stack backtraces - running the same executable under gdb until it receives a
provoked SIGSEGV yields a proper backtrace.

*** Received output:
Signal 11 in dump_trace - have 0 frames

*** Expected output SIMILAR TO (this is taken from the same program under Linux
- only adapted to use int, not size_t, and omitting -lexecinfo because
backtrace is part of GNU libc):
Signal in dump_trace - have 8 frames
./try-bt[0x401185]
/lib64/libc.so.6(+0x3c6b0)[0x7f951de3a6b0]
./try-bt(boom+0x10)[0x4011e0]
./try-bt(two+0xe)[0x4011f4]
./try-bt(one+0xe)[0x401205]
./try-bt(main+0x1d)[0x401225]
/lib64/libc.so.6(__libc_start_main+0xf3)[0x7f951de251a3]
./try-bt(_start+0x2e)[0x4010ae]



*** Program:

/* save as try-bt.c then compile with:
cc -rdynamic -fno-omit-frame-pointer -g -std=c99 -o try-bt try-bt.c -fno-inline
-lexecinfo -lelf */
#include <execinfo.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>

static void dump_trace(int sig) {
        size_t max_frames = 32;
        void *buffer[max_frames];
        size_t calls = backtrace(buffer, max_frames);
        fprintf(stderr, "Signal %d in dump_trace - have %zu frames\n", sig,
calls);
        backtrace_symbols_fd(buffer, calls, 2);
        _Exit(EXIT_FAILURE);
}

void boom() {
        volatile char *a = 0;
        *a = 17;
}

void two() {boom(); }
void one() {two(); }

int main(void) {
        signal(SIGSEGV, dump_trace);
        one();
        exit(EXIT_SUCCESS);
}
/* END */

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list