Skip to content

native: report panic source locations and stack backtraces - #2120

Open
sbillig wants to merge 5 commits into
argotorg:masterfrom
sbillig:feat/native-panic-backtrace
Open

sbillig wants to merge 5 commits into
argotorg:masterfrom
sbillig:feat/native-panic-backtrace

Conversation

@sbillig

@sbillig sbillig commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Emit source file:line:col locations and stack backtraces on host-native panics, reverts, todo!(), assert!(), unwrap(), overflow/division-by-zero traps, bounds traps, and OOM aborts (DWARF output deferred for now).
  • Use the new Cranelift frame-pointer preservation + on-demand .data.rel.ro/.rodata symtab hooks (fe-lang/sonatina#633) to unwind cleanly across PIE/ASLR executables, stripped binaries, and stripped -fomit-frame-pointer C staticlib callers.
  • Perform all panic formatting and backtrace unwinding in core::rt using zero heap allocations (compiler-managed .bss scratch buffers __fe_panic_buf / __fe_panic_data_buf / __fe_panic_active, division-free div_10, and re-entrancy guard) so real OOM panics still print their location and stack backtrace cleanly before fflush + abort.
  • Keep panic-free native binaries and bare WASM modules free of panic hooks, runtime globals, and symtab data by pruning unreachable panic accessors post-optimization (finalize_module_panic_state).
  • Preserve fe test --backend native should_revert / panic = ... semantics while printing source locations and backtraces on unexpected test traps.

Dependency Note

  • Depends on cranelift: preserve native frame pointers and emit panic symtab hooks fe-lang/sonatina#633 (cranelift: preserve native frame pointers and emit panic symtab hooks).
  • Because Fe currently pins Sonatina at daca656 (before the upstream fe-lang/sonatina main Cranelift refactors), Cargo.toml temporarily points the sonatina-* dependencies at https://github.com/sbillig/sonatina rev 200ddea0a2e626c6957a23ca2b17e68a884e273d (fe-lang/sonatina#633 ported cleanly onto daca656) until Fe bumps its upstream Sonatina pin.

Testing

  • cargo test --profile test-release -p fe --features cranelift --test native_runtime (89 passed; 0 failed)
  • cargo test --profile test-release -p fe-codegen --features "cranelift wasm" (all suites passing, including native_backend 23/23)
  • cargo test --profile test-release -p fe --features "cranelift wasm" --test wasm_files (15 passed; 0 failed)
  • cargo test --profile test-release -p fe --features "cranelift wasm" --test wasm_test_command (16 passed; 0 failed)
  • cargo fmt --all -- --check & cargo clippy -p fe-mir -p fe-codegen -p fe --all-targets --features "cranelift wasm" -- -D warnings

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T20:49:25.735532Z 441a020 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfc4feec15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mir/src/runtime/lower/body.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c4fa216f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54464d7f26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mir/src/runtime/lower/body.rs Resolved

This branch has not been deployed

No deployments
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