lean_vm: add source-level failure stack traces#246
Draft
latifkasuli wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fpunwinder that prints frames from the failing function back tomainExecutionOptions/CompileAndRunOptionsplusLEANVM_STACK_TRACE=0for legacy callers to disable stack trace printingpc/fpforparallel_rangefailures and hide compiler-generated loop helper frames from the rendered stackCloses #112.
Root cause
The existing diagnostic path inferred call stacks from source-location history. That could show useful source context, but it was not organized by the live caller/callee relation and could not reliably print the current VM frame chain from the failing function back to
main.Implementation notes
Touched surfaces:
crates/lean_compiler/src/b_compile_intermediate.rscrates/lean_compiler/src/c_compile_final.rscrates/lean_compiler/src/ir/instruction.rscrates/lean_compiler/src/lib.rscrates/lean_compiler/tests/test_compiler.rscrates/lean_vm/src/diagnostics/stack_trace.rscrates/lean_vm/src/execution/runner.rscrates/lean_vm/src/isa/bytecode.rsThe unwinder follows the VM call convention (
mem[fp] = return_pc,mem[fp + 1] = saved_fp) and has three safety guards: a 256-frame cap, repeated-fpdetection, and checked memory reads. If the cap is hit while another frame is readable, the rendered trace includes a truncation marker.Bytecodegains debug-only call-site metadata incall_sites_by_return_pc. I checked repository serialization usage:Bytecodedoes not derive or implement serde serialization/deserialization, and aggregation bytecode is compiled into aOnceLockat runtime rather than loaded from a persisted bytecode blob.Sequencing / collision notes
This intentionally opens as a draft because the collision surface is real:
crates/lean_vm/src/execution/runner.rsandcrates/lean_compiler/src/c_compile_final.rs, including parallel execution work.runner.rs,c_compile_final.rs, andtest_compiler.rs.crates/lean_compiler/src/lib.rs; if lean_compiler: avoid duplicate compile-and-run output #245 lands first, this should be rebased before review.Validation
cargo test -p lean_compiler runtime_failure -- --nocapturecargo test -p lean_compilercargo fmt --checkgit diff --checkcargo check --workspacecargo clippy --workspace --all-targets -- -D warnings