loader: unwind a 16-byte aligned copy of the context #313
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!313
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/313/head"
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?
@Abdellah-Khanani on GitHub · 2026-11-24 02:14 UTC · original
Abdellah-Khanani:loader-aligned-unwind→main· +15 −5 · 1 files · 1 commits · merged 2026-11-24 08:00 UTCunwind_intohands its by-valueCONTEXTtoRtlVirtualUnwind, andunwinds_like_the_system_walkhands a stackCONTEXTtoRtlCaptureContext. Both functions want the context 16-byte aligned. windows-sys 0.61 declares the x64CONTEXTas plain#[repr(C)], with noalign(16), so on the stack it can land 8 bytes off.In a debug build here it does.
cargo test --workspaceonmain(d2a4bae) stops the wholevictory-loadertest binary withthread 'crash::tests::unwinds_like_the_system_walk' has overflowed its stackandSTATUS_ACCESS_VIOLATION, so the other 17 loader tests are not counted. A temporary print showed the test's context at an address ending in...838. Release builds happen to get an aligned slot and pass.Aligning only the test's context is not enough: the test still crashes inside
unwind_into, on its own copy. The same copy is what the crash handler (unwind(*context)) andstacks.rs(unwind_into(context.0, …)) unwind with, so a debug or diagnostics build can fault while writing a crash report.What is in it
crates/victory-loader/src/crash.rs: anAligned16(CONTEXT)wrapper (#[repr(C, align(16))], like the privateAlignedinstacks.rsforGetThreadContext).unwind_intocopies its context into one and unwinds that.unwinds_like_the_system_walkcaptures into one.Tested
rust-toolchain.toml.cargo test --workspace --no-fail-fastonmaind2a4bae: 246 passed, 0 failed, 4 ignored, plus thevictory-loaderlib binary aborted (0xc0000005, the stack-overflow message above).cargo test -p victory-loader, debug and--release: 18 + 2 passed in both.unwind_into), the debug test still crashes the same way.cargo fmt --check -p victory-loader: no new differences (10 before and after, all in lines this does not touch).Not tested
VICTORY_STACKS, in a diagnostics build.AI use
🤖 Generated with Claude Code
@arminkhaleghirod on GitHub · 2026-11-24 03:04 UTC · original
Confirmed on Windows 11. On main,
unwinds_like_the_system_walkcrashes every run in debug. With this PR it passes.@qntic on GitHub · 2026-11-24 07:49 UTC · original
Independent test on a Zen 3 machine: confirms the fix.
Environment: Windows 11 22631, AMD Ryzen 5 5600X (Zen 3), AMD Radeon RX 6600 XT, 32 GB, Rust 1.98.1 from
rust-toolchain.toml, debug,--locked. This PR cherry-picked ontod2a4bae(tree identical tob5c6678).Before (
d2a4bae):cargo test --locked -q -p victory-loader --libaborts in 3 of 3 runs withthread 'crash::tests::unwinds_like_the_system_walk' has overflowed its stackand0xc0000005, STATUS_ACCESS_VIOLATION. The test alone aborts the same way.After (this PR):
victory-loaderlib: 18 passed, 0 failed, in 3 of 3 runs.cargo test --workspace --locked --no-fail-fast: 264 passed, 0 failed, 4 ignored, exit code 0. These are the same totals as in the PR description, on a different CPU generation (Zen 3 here, Zen+ there).Not tested: a release build of the loader tests, the crash handler on a real crash,
VICTORY_STACKS, any title.