ianlancetaylor / libbacktrace

A C library that may be linked into a C/C++ program to produce symbolic backtraces
Other
982 stars 228 forks source link

libbacktrace fails on macOS Sequoia #136

Closed nolaforensix closed 3 weeks ago

nolaforensix commented 1 month ago

Hi,

libbacktrace seems to fail on macOS Sequoia , both using make check and in the application in which I've used it for some time. Here's the log generated by make check:

thelonious:libbacktrace golden$ cat test-suite.log

package-unused version-unused: ./test-suite.log

TOTAL: 21

PASS: 11

SKIP: 0

XFAIL: 0

FAIL: 10

XPASS: 0

ERROR: 0

.. contents:: :depth: 2

FAIL: allocfail.sh

FAIL allocfail.sh (exit status: 1)

FAIL: btest

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) FAIL: backtrace_full noinline FAIL: backtrace_full inline FAIL: backtrace_simple noinline FAIL: backtrace_simple inline PASS: backtrace_syminfo variable FAIL btest (exit status: 1)

FAIL: btest_alloc

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) FAIL: backtrace_full noinline FAIL: backtrace_full inline FAIL: backtrace_simple noinline FAIL: backtrace_simple inline PASS: backtrace_syminfo variable FAIL btest_alloc (exit status: 1)

FAIL: edtest

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 FAIL: backtrace_full alloc stress FAIL edtest (exit status: 1)

FAIL: edtest_alloc

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 FAIL: backtrace_full alloc stress FAIL edtest_alloc (exit status: 1)

FAIL: ttest

DW_FORM_addrx value out of range DW_FORM_addrx value out of range DW_FORM_addrx value out of range DW_FORM_addrx value out of range DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) DW_FORM_addrx value out of range DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) DW_FORM_addrx value out of range test1: not enough frames; got 0, expected at least 3 DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 FAIL: threaded backtrace_full noinline FAIL ttest (exit status: 1)

FAIL: ttest_alloc

DW_FORM_addrx value out of range DW_FORM_addrx value out of range DW_FORM_addrx value out of range DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) DW_FORM_addrx value out of range DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) DW_FORM_addrx value out of rangetest1: not enough frames; got 0, expected at least 3 DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3

no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 FAIL: threaded backtrace_full noinline FAIL ttest_alloc (exit status: 1)

FAIL: dwarf5

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) FAIL: backtrace_full noinline FAIL: backtrace_full inline FAIL: backtrace_simple noinline FAIL: backtrace_simple inline PASS: backtrace_syminfo variable FAIL dwarf5 (exit status: 1)

FAIL: dwarf5_alloc

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) FAIL: backtrace_full noinline FAIL: backtrace_full inline FAIL: backtrace_simple noinline FAIL: backtrace_simple inline PASS: backtrace_syminfo variable FAIL dwarf5_alloc (exit status: 1)

FAIL: mtest

DW_FORM_addrx value out of range no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) test1: not enough frames; got 0, expected at least 3 FAIL: backtrace_full noinline PASS: backtrace_simple noinline PASS: backtrace_syminfo variable FAIL mtest (exit status: 1)

ianlancetaylor commented 1 month ago

Which version of clang are you using?

Also, which version of libbacktrace? The symptoms are similar to a bug that was fixed in revision 4ead348bb45f753121ca0bd44170ff8352d4c514.

nolaforensix commented 1 month ago

Hi,

It's the clang installed with Sequoia's version of XCode and a fresh git clone from the repo:

thelonious:scalpel3 golden$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
pnsafonov commented 1 month ago

Bug is reproduced.

% clang --version Apple clang version 16.0.0 (clang-1600.0.26.3) Target: arm64-apple-darwin24.0.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin libbacktrace_macos_tests.txt

macOS Sequoia 15.0

latest version of master libbacktrace: commit 86885d14049fab06ef8a33aac51664230ca09200 (HEAD -> master, origin/master, origin/HEAD) Author: Ian Lance Taylor iant@golang.org Date: Tue Jul 16 21:27:05 2024 -0700

pnsafonov commented 1 month ago

backtrace_error_callback error_callback returns this: msg = no debug info in Mach-O executable (make sure to compile with -g; may need to run dsymutil) errnum = -1

nolaforensix commented 1 month ago

This is probably already clear, but just wanted to make sure: The executable IS compiled with -g and dsymutil was also run and the error occurs anyway.

pnsafonov commented 1 month ago

This is probably already clear, but just wanted to make sure: The executable IS compiled with -g and dsymutil was also run and the error occurs anyway.

I checked: binary compiled with -g option, symbol table exists in binary and correct.

ianlancetaylor commented 1 month ago

@pnsafonov The question is not so much the symbol table, it is where the debug information is. There is a bunch of code in libbacktrace to find it. Evidently that code is failing, but how?

nolaforensix commented 4 weeks ago

clang 16 changes are here: https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#dwarf-support-in-clang

Is the following the breaking change?

**DWARF Support in Clang Previously when emitting DWARFv4 and tuning for GDB, Clang would use DWARF v2’s DW_AT_bit_offset and DW_AT_data_member_location. Clang now uses DWARF v4’s DW_AT_data_bit_offset regardless of tuning.

Support for DW_AT_data_bit_offset was added in GDB 8.0. For earlier versions, you can use the -gdwarf-3 option to emit compatible DWARF.**

ianlancetaylor commented 4 weeks ago

@nolaforensix Thanks, but, no, that shouldn't make a difference. Those are for locating variables in memory, which libbacktrace doesn't care about.

pnsafonov commented 3 weeks ago

This is fix for this issue: https://github.com/ianlancetaylor/libbacktrace/pull/143

Tests on macOS are passed, backtrace working fine.

nolaforensix commented 3 weeks ago

Confirmed working, thanks for the quick fix!