libbacktrace icon indicating copy to clipboard operation
libbacktrace copied to clipboard

libbacktrace fails to parse debug symbols on macOS ARM64 with Apple Clang 17

Open sangbida opened this issue 5 months ago • 3 comments

Hello, I'm encountering the following error when using libbacktrace with a binary compiled on macOS:

lightningd/lightningd: libbacktrace: DW_FORM_addrx value out of range
lightningd/lightningd: libbacktrace: failed to read executable information

I'm running: macOS 15.4.1 (24E263) Apple clang version 17.0.0 (clang-1700.0.13.5) Target: arm64-apple-darwin24.4.0 libbacktrace version: Latest master (commit 7939218)

I think libbacktrace seems to work fine on Core Lightning on Linux but doesn't work on MacOS. I get the above error when I try to compile core lightning and run a broken test.

What I've tried so far:

  • Updated the libbacktrace submodule on core lightning to include this commit
  • Modified debug flags in the configure script to use -gdwarf-4 instead of the default DWARF version.
CDEBUGFLAGS="-std=gnu11 -g -gdwarf-4 -fstack-protector-strong"
  • Added dsymutil support in the main Makefile

I've added my changes to the config and makefile here: https://github.com/sangbida/lightning/commit/8e459d31b143dc0928e5394ce9de406924a28e21

Despite these changes, the "DW_FORM_addrx value out of range" error persisted 😭 Please let me know if there's anything that I'm doing obviously wrong here, which I hope I am because I would dearly love to resolve this!

sangbida avatar Jul 29 '25 02:07 sangbida

I don't see anything obviously wrong.

I don't have access to a macOS ARM64 machine so I don't have a way to debug this. The first step would be to confirm that your executable has a __debug_addr section. If it does, perhaps you can run the program under the debugger and set a breakpoint on the error callback routine to see what the values are that are out of range.

ianlancetaylor avatar Jul 29 '25 03:07 ianlancetaylor

Okay, so it works now! However, I didn't make any further changes to the config beyond that point. Not really sure what changed? But my changes are here on this PR: https://github.com/ElementsProject/lightning/pull/8431 and backtraces seem to work!

sangbida avatar Jul 29 '25 06:07 sangbida

Glad it's working for you. Sounds like there is a bug somewhere for LLVM with -gdwarf-5. Leaving this open in case somebody with access to macOS arm64 is able to investigate.

ianlancetaylor avatar Jul 30 '25 00:07 ianlancetaylor