Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jan 2020 22:25:26 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 243746] backtrace() not returning any stack frames [12.1-RELEASE-p1 amd64]
Message-ID:  <bug-243746-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D243746

            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@FreeBSD.org
          Reporter: mandree@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 fi=
nd
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 L=
inux
- 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=3Dc99 -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 =3D 32;
        void *buffer[max_frames];
        size_t calls =3D 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 =3D 0;
        *a =3D 17;
}

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

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

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-243746-227>