A crash through a bad function pointer keeps its caller in the checked stack walk #378
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!378
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-378"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@thejacte on GitHub · 2026-11-26 22:53 UTC · original
thejacte:claude/a-publier-unwind-null-caller→a-publier· +35 −15 · 1 files · 1 commits · openFollow-up to #343, from JonyWater's review there: with
VICTORY_UNWIND_CHECKSon, a call through a null or garbage function pointer lost its caller. The faulting RIP isn't executable, so the first step broke before the leaf rule could read the return address at[rsp]. The old walk showed that caller, and it's usually the most useful line in a crash report.Now the first frame takes the leaf rule whatever RIP points at: null, unreadable, not executable, or outside an image.
[rsp]is still read throughReadProcessMemory, and frames after the first still need executable image code. Profiles aren't affected, since a suspended thread's RIP is real code.A second pass found one more edge case: a caller whose return address was the stack's last word was dropped, because the step after it refused
RSP == high. It is kept now. The top of the loop still stops before any read past the stack.Tests (
crates/victory-loader/src/crash.rs):takes_the_caller_of_a_call_through_a_null_pointer: RIP = 0 and a one-word stack. The test expects exactly[0, caller], which also covers the last-word case.stops_at_a_pc_outside_an_image_after_the_first_frame: the leaf rule returns into non-executable data, and the walk stops there. This replacesstops_at_a_pc_outside_an_image.Checked on a-publier at
4eb6cfd:cargo clippy --workspace --all-targets --locked -- -D warnings: no warnings--all-features: no warningscargo test -p victory-loader --locked: 57 passedcargo xtask policy: passes (271 files)Not covered here: JonyWater's other note, about the
clzeroand write-site stubs entered byjmp(their second frame is junk, as it was with the old walk). That belongs in its own issue.Written with Claude Code; reviewed by Codex and a rust-reviewer pass against
upstream/rx9070xt(the same code; a-publier's crash.rs matches #343).🤖 Generated with Claude Code
@lvndrpup on GitHub · 2026-11-27 04:55 UTC · original · reviewed
Checked on Windows 11 build 26300, Rust 1.98.1, debug. To see that the new tests catch the old behaviour, I ran them against
4eb6cfd's walk, takingcrash.rsfrom4eb6cfdup tomod testsand this PR's tests after it:cargo test -p victory-loader --lib -- crash::4eb6cfd's walk, this PR's tests01d3f8c)takes_the_caller_of_a_call_through_a_null_pointerleft: [0](the caller is lost)stops_at_a_pc_outside_an_image_after_the_first_frameleft: [0],right: [0, 330048724536]At
01d3f8c,cargo test -p victory-loaderpasses (57 lib tests), andcargo clippy -p victory-loader --all-targets -- -D warningsis clean, with and without--all-features. I did not run a real crash through a bad pointer; these results come from the unit tests' synthetic stacks only.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.