Repository navigation
fix(ir): record the throw call's line in its stack frame - #93
Merged
Merged
Conversation
People debugging a Nera program now see the real line of a throw: in a caught stacktrace, in the exit reason a monitor or link receives, and in the crash message printed when a process dies. A new test checks this in compiled Nera programs and runs unchanged on BEAM.
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.
Why
When a program used throw/1, the error details pointed at line 0, or at the wrong line, instead of the line holding the throw. BEAM and Nera's own error/1 point at the right line.
What changed
Before and after
Before: With throw/1 on line 5 and a throw after another call on line 9, Nera reported lines 0 and 8, while BEAM OTP 29 reported 5 and 9.
After: The same program reports lines 5 and 9, matching BEAM, and the crash message prints line 5.
Nothing on a screen changes: the fix shows in error details and crash messages, which the checks below record as text.
Checked
How it was checked
cargo build --release --locked -p nera-runtime && cargo build --release --locked -p nera
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked --no-fail-fast
python3 scripts/test-allocator-config.py
./target/release/nera test -j 1 --timeout 30
python3 scripts/test-stacktrace-order.py
./target/release/nera test throw_stacktrace_line (10 runs, and 10 with NERA_SCHEDULERS=1)
erlc tests/throw_stacktrace_line.erl && erl -noshell -eval 'ok = throw_stacktrace_line:test(), halt().' (10 runs, OTP 29)
Risk
Risk: low in every dimension.
Full risk assessment
Not done
Three related defects seen on the way are tracked separately: inline runtime errors such as badarith can name a stale line, a tail-call apply of a raising function drops the caller's frame, and fun erlang:throw/1 does not compile.