Skip to content

Conversation

@sangbida
Copy link
Collaborator

@sangbida sangbida commented Jul 29, 2025

On macOS, libbacktrace was failing to find debug information due to:

  1. Debug symbols not being properly linked with dsymutil
  2. Apple Clang 17.0.0 generating DWARF 5 which libbacktrace couldn't parse

In this commit we address both issues:

Debug symbol accessibility:

  • Add dsymutil integration in Makefile to properly link debug symbols

DWARF format compatibility:

  • Force -gdwarf-4 instead of default DWARF 5 to avoid "DW_FORM_addrx value out of range" errors
  • Update the version of libbacktrace being used in core-lightning (see commit)

Changelog-added: libbacktrace works with macOS

Example stacktrace:

sangbida@Sangbidas-MacBook-Pro lightning % ./lightningd/lightningd
lightningd: FATAL SIGNAL 6 (version v25.05-62-g3622a81-modded)
0x102833dcb send_backtrace
        common/daemon.c:33
0x1028344db crashdump
        common/daemon.c:78
0x185a6f623 ???
        ???:0
0x185a3588b ???
        ???:0
0x18593ec5f ???
        ???:0
0x1027ae32b main
        lightningd/lightningd.c:1217
zsh: abort      ./lightningd/lightningd

Important

25.09 FREEZE July 28TH: Non-bugfix PRs not ready by this date will wait for 25.12.

RC1 is scheduled on August 11th

The final release is scheduled for September 1st.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

@ddustin
Copy link
Collaborator

ddustin commented Aug 1, 2025

Amazing!

…lity

On macOS, libbacktrace was failing to find debug information due to:
1. Debug symbols not being properly linked with dsymutil
2. Apple Clang 17.0.0 generating DWARF 5 which libbacktrace couldn't parse

In this commit we address both issues:

Debug symbol accessibility:
- Add dsymutil integration in Makefile to properly link debug symbols
- Use -fno-standalone-debug to embed debug info inline in executable

DWARF format compatibility:
- Force -gdwarf-4 instead of default DWARF 5 to avoid "DW_FORM_addrx value out of range" errors

Changelog-added: libbacktrace works with macOS
When installing core lightning on macOS I found that the debug symbols were not being preserved leading to  "no debug info in
Mach-O executable". This is because the .dSYM files, which contain the debug information, is generated in the build directory and could not be found by the installed binaries.

Changes:
- Add -fno-standalone-debug flag to CDEBUGFLAGS on macOS to reduce
  dependency on absolute source paths
- Modify install-program target to copy .dSYM bundles alongside
  binaries for BIN_PROGRAMS, PKGLIBEXEC_PROGRAMS, and PLUGINS

Testing:
1. ./configure --reconfigure
2. make install PREFIX=/tmp/lightning-install
3. make clean (removes all .dSYM files from build directory)
4. /tmp/lightning-install/bin/lightningd --help
5. Verified stack traces now work correctly without "no debug info" errors
@sangbida sangbida force-pushed the fix-libbacktrace-macos branch from 0bdf81b to 00563e5 Compare August 3, 2025 05:58
@ddustin
Copy link
Collaborator

ddustin commented Aug 4, 2025

image Looks like its working for me! Awesome fix.

ACK 00563e5

@madelinevibes madelinevibes added the Status::Ready for Review The work has been completed and is now awaiting evaluation or approval. label Aug 6, 2025
@rustyrussell rustyrussell merged commit 9e55e8d into ElementsProject:master Aug 6, 2025
76 of 78 checks passed
PastaPastaPasta added a commit to dashpay/dash that referenced this pull request Nov 14, 2025
… make detection more robust, refactor and add platform-specific checks, add linker and compiler flags

0d1d6d3 fix: resolve compile errors in `stacktraces.cpp` on Windows (Kittywhiskers Van Gogh)
2699740 fix: use `-fno-standalone-debug` on macOS, `-gdwarf-4` on non-Windows (Kittywhiskers Van Gogh)
c5c8baf fix: set `-export-dynamic` to ensure symbols are preserved (Kittywhiskers Van Gogh)
fc77534 build: if enabling stacktraces, search for `libexecinfo` on BSDs (Kittywhiskers Van Gogh)
9998bf6 fix: improve libbacktrace detection (Kittywhiskers Van Gogh)
bc762cc build: move `BACKTRACE_LIBS` determination to `configure.ac` (Kittywhiskers Van Gogh)
b73deae build: s/BACKTRACE_LIB/BACKTRACE_LIBS/g (Kittywhiskers Van Gogh)
e41899e refactor: consolidate enhanced debugging logic (Kittywhiskers Van Gogh)
046d87a depends: ianlancetaylor/libbacktrace@b9e40069c0 (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * ianlancetaylor/libbacktrace@b9e40069c0 includes fixes relevant to us, specifically [`3fda5a87`](ianlancetaylor/libbacktrace@3fda5a8), [`d48f8403`](ianlancetaylor/libbacktrace@d48f840) as they relate to handling of Mach-O

  * On BSDs, `libexecinfo` ([source](https://www.freshports.org/devel/libexecinfo)) is a distinct library (unlike Linux, where it is bundled as part of `glibc`) that needs to be obtained in order for stacktraces to work, we will now explicitly specify we want to link against this dependency when we configure the build.

  * `libbacktrace` is known to have issues with DWARF 5 parsing (see [ianlancetaylor/libbacktrace#158](ianlancetaylor/libbacktrace#158)) and we are therefore adapting the fix implemented in [ElementsProject/lightning#8431](ElementsProject/lightning#8431) to ensure that we emit DWARF 4 binaries that should work with `libbacktrace`.

  * It appears that until this PR, some portions of our stacktrace code weren't being built on Windows which revealed some compile errors ([build](https://github.com/dashpay/dash/actions/runs/19303109295/job/55206686088#step:8:1806)), they have been resolved in a separate commit.

  * We need to make sure that we build with `-export-dynamic` (or `-rdynamic` on certain compilers, [source](https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html)) to ensure symbol data is preserved for generating backtraces.

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)**
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK 0d1d6d3
  UdjinM6:
    utACK 0d1d6d3

Tree-SHA512: 02aa71e3a8aae0bddf677fd71319356090a6f97b036e079631dce58a8ba52d6d4971c8f33aaf43fdae35df36cfd3475dda9bba64df81ef579596797c8f6a1d7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status::Ready for Review The work has been completed and is now awaiting evaluation or approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants