Files
FTL/test
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
..
2025-12-14 19:08:55 +01:00