Dominik 227b69573d Add universal crash backtrace via _Unwind_Backtrace
Replace the glibc-only execinfo.h backtrace with _Unwind_Backtrace
from GCC's libgcc, which works on glibc and musl, static-pie and
dynamic, across all supported architectures.

Key design decisions:
- __ehdr_start (GNU ld linker symbol) gives the PIE load base
  reliably on all targets, replacing dl_iterate_phdr which does not
  enumerate the main executable consistently on musl static builds
- SOURCE_ROOT compile definition strips the build machine prefix so
  backtraces show project-relative paths (src/signals.c:42)
- dladdr() resolves dynamic symbol names from .dynsym for stripped
  shared-library frames; /proc/self/maps provides the library name
  as fallback when no symbol is exported
- Each frame is logged as a single line:
    #N  func_name    src/file.c:line   (resolved)
    #N  0xADDRESS    (libc.so.6  sym+off)  (unresolved)

New subcommands:
- crash:     triggers a deterministic SIGSEGV via mmap(PROT_NONE)
             (not UB, not elided by the optimizer, not caught by
             sanitizers) to validate the crash handler end-to-end
- backtrace: prints a live backtrace without crashing, for manual
             inspection on a given build or platform

CI: add check_crash() to test/arch_test.sh, called unconditionally
for every architecture to verify the handler fires and a backtrace
is produced.

Bug fixes:
- removePID(): guard config.files.pid.v.s != NULL before fopen()
  to prevent a secondary SIGSEGV when config was never loaded
  (e.g. crash/backtrace subcommands)
- signal_handler(): fflush(stdout) immediately after generate_backtrace()
  so the output is preserved even if cleanup() faults on uninitialized
  state before exit() can flush stdio

Signed-off-by: Dominik <dl6er@dl6er.de>
2026-03-20 14:11:13 +01:00

Pi-hole logo
Network-wide ad blocking via your own Linux hardware

FTLDNS logo

FTLDNS (pihole-FTL) provides an interactive API and also generates statistics for Pi-hole®'s Web interface.

  • Fast: stats are read directly from memory by coupling our codebase closely with dnsmasq
  • Versatile: upstream changes to dnsmasq can quickly be merged in without much conflict
  • Lightweight: runs smoothly with minimal hardware and software requirements such as Raspberry Pi Zero
  • Interactive: our API can be used to interface with your projects
  • Insightful: stats normally reserved inside of dnsmasq are made available so you can see what's really happening on your network

Official documentation

The official FTLDNS documentation can be found here.

Installation

FTLDNS (pihole-FTL) is automatically installed when installing Pi-hole.

IMPORTANT

FTLDNS will disable any existing installations of dnsmasq. This is because FTLDNS is dnsmasq + Pi-hole's code, so both cannot run simultaneously.

S
Description
Languages
C 96.9%
C++ 1.1%
Python 0.9%
Shell 0.7%
CMake 0.3%