Crash reports: end the stack walk where rtlvirtualunwind faults #1897
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1897
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1897"
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?
@imjustprism on GitHub · 2026-11-25 00:19 UTC · original
imjustprism:fix/unwind-frame-register→main· +1780 −226 · 6 files · 3 commits · opena crash on a smashed frame (a frame register or return address pointing at memory that is not there) made RtlVirtualUnwind fault inside our vectored handler, so the report was lost and the process died in the handler. the unwind call now runs through a small trampoline: on a memory fault raised inside ntdll the handler ends that call and the walk stops with a
walk ended: ...line naming the fault. only the first exception of a call is recovered, and a guard page read on another thread's stack is put back.three commits: the walk moves to its own module, walks are bounded by the committed stack (an rsp in the reserved part of the stack with no function entry was read unguarded), then the guarded call.
tested on windows 11 26200, ryzen 7 9800x3d, full gate green. the child tests die with 0xc0000005 without the recovery. 10,000 recovered faults leave function tables and panic unwinding usable. not covered: a fault inside the search of a registered function table whose entries are gone, and statuses RtlVirtualUnwind raises itself (those end the process as before). it relies on the exe not being shadow-stack (cet) compatible, which it is not today.
4dd7541044to7e71820b1e@AgneyaK on GitHub · 2026-11-25 06:18 UTC · original
Native test report: Windows 11 26300 (i7-13700H), MSVC, PR head
4dd75410merged ontomain940d32f(clean merge).cargo test -p victory-loader -p victory-pe --locked, 10 full runs, all identical and green: loader 56 + 1 + 2 + 1, pe 36, 0 failed. That matters here, since several tests fault on purpose in child processes and on guard pages.recover_unwind_faultdecline everything (if true || …on its early-return line) and ran the lib tests again. The test process died partway (28 of 56 done) with exit code0x80000001(STATUS_GUARD_PAGE_VIOLATION), so the guard-page and fault tests do depend on the recovery and aren't passing vacuously.cargo clippy -p victory-loader -p victory-pe --all-targets --locked -- -D warnings, with and without--all-features: clean..seh_*directives match the saves: 8 pushes, 232 bytes, xmm6–15 at 64…208.rspstays 16-byte aligned for themovapsand the call.GUARDEDis set, andGUARDEDis taken withreplace(null), so a second fault in the same call isn't recovered. That matches the description.Not tested: a real title crash with a smashed frame. None of my recent title runs crashed in a way that would reach this path.
AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this.
@Marvisak on GitHub · 2026-11-25 08:16 UTC · original · edited 2026-11-26 07:20 UTC
Automated triage for the maintainers.
Merge candidate. Rebased onto
main; merges cleanly, in three commits:crates/victory-loader/src/unwind.rs.RtlVirtualUnwindruns through thevictory_guarded_calltrampoline.recover_unwind_faultrecovers only an access violation, guard-page violation or in-page error raised inside ntdll's image range during a guarded call. It takesGUARDEDwithreplace, so only the first exception counts, and it puts back a cleared guard page. The prologue saves and.seh_*offsets match (8 pushes, 232 bytes, xmm6-15 at 64..208), and the recovery path restores MXCSR, the x87 control word and DF. Because it rewritesRip/Rspin an exception handler, a maintainer should read it carefully. Optional: the long rustdoc onrecover_unwind_fault, which includes a measurement log, could be trimmed.CI: passing.
Generated by Claude Code
end the stack walk where rtlvirtualunwind faultsto Crash reports: end the stack walk where rtlvirtualunwind faults@catminou4 on GitHub · 2026-11-25 02:17 UTC · original · reviewed
Static review only: crash-handler/stack-walk code is Windows-only (rtlvirtualunwind) — nothing compiles on macOS; source review of the diff.
Bounding the stack walk where rtlvirtualunwind faults prevents the crash handler itself from crashing — good hardening, pairs with #1539's crash.rs work.
@fuzeofficlal on GitHub · 2026-11-26 11:15 UTC · original · requested changes
The guarded unwind trampoline design looks very solid: the x64 Win64 prologue/epilogue and
.seh_*directives align the stack properly and preserve all nonvolatile GPRs, XMM6–XMM15, MXCSR, x87 CW, and DF; single-shotGUARDEDconsumption,UNWINDER_IMAGEfiltering, guard-page re-arming, and post-GetThreadContextTEB reads instacks.rsall check out cleanly. All 57victory-loaderdev tests and integration tests pass.Two issues need attention before merge:
Blocking — two new tests fail in
--releasebuilds (crates/victory-loader/src/unwind.rs:776):Running
cargo test --release -p victory-loader --libfails deterministically (55 passed, 2 failed) on:unwind::tests::a_frame_register_outside_the_stack_ends_the_walkunwind::tests::a_frame_register_in_the_uncommitted_stack_ends_the_walkBoth child processes panic at
crates/victory-loader/src/unwind.rs:776:In
walk_with_frame_register:Because
&Line([0; 64]).0is a shared reference to a constant all-zero rvalue, rustc promotes it to static.rdataunder--release, so the function no longer needs 64-byte stack realignment and LLVM omits therbpframe pointer. Binding a mutable local on the stack (let mut line = Line([0; 64]); std::hint::black_box(&mut line.0);) prevents static promotion and keeps the frame register in release builds as well.Overflow in stack-bounds check (
crates/victory-loader/src/unwind.rs:104):In
unwind_into:If a corrupted frame leaves
context.Rspinu64::MAX - 6..=u64::MAX,rsp >= lowholds whilersp + 8either panics on arithmetic overflow in debug builds (inside the vectored handler) or wraps to0..=6 < highin release builds, bypassing the bounds check and dereferencing(rsp as *const u64).read()outsidentdll(whererecover_unwind_faultdeclines recovery). Usingrsp.checked_add(8).is_none_or(|end| end > high)closes that gap cleanly.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.