Skip to content

Restore Terra's native backtrace facility on modern LLVM - #740

Merged
elliottslaughter merged 1 commit into
terralang:masterfrom
elliottslaughter:backtraces
Aug 18, 2026
Merged

elliottslaughter merged 1 commit into
terralang:masterfrom
elliottslaughter:backtraces

Conversation

@elliottslaughter

Copy link
Copy Markdown
Member

JIT mode backtraces have been broken for a long time, at least since LLVM 8 (and possibly earlier; the test was locked to LLVM 3.5).

This PR restores JIT mode backtraces and Terra's native backtrace functionality in general. Specifically:

  • Adds back terralib.traceback for modern LLVM (11-22)
  • Restores the associated functionality terralib.lookupsymbol and terralib.lookupline
  • Backtraces work on AArch64 as well as x86-64 now
  • Enable frame pointers on -g only: note this impacts objects generated with terralib.saveobj as well as JIT mode
  • This means that users without -g will see the top stack frame only, along with a message to run with -g to see more
  • Various fixes for the signal handlers: using an mmapped altstack with guard pages, coverage for SIGBUS and SIGFPE
  • Signal handlers now fflush(0) to ensure we don't lose stack trace or user output when re-raising
  • New tests ensure this functionality stays working, not dependent on LLVM version

The main thing not working yet is Windows stack traces: the symbol lookup works fine but the frame pointer based stack scanning is not sufficient so at the moment you only get one stack frame on Windows.

@elliottslaughter
elliottslaughter merged commit 55784d7 into terralang:master Aug 18, 2026
78 checks passed
@elliottslaughter
elliottslaughter deleted the backtraces branch August 18, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant