Loader: guard null C++ exception pointers in crash::thrown and Rsp overflow/alignment in unwind_into #2554
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!2554
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2554"
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?
@reeledMarek on GitHub · 2026-11-25 15:40 UTC · original
reeledMarek:fix/loader-crash-thrown-and-unwind→main· +65 −12 · 1 files · 1 commits · openProblem
crash::thrown, MSVC C++ rethrows (throw;) passp[1] == 0andp[2] == 0, and malformed exception metadata can have zero RVAs orcount == 0.thrownunconditionally dereferencedp[2] + 12,name(0), andp[1] + 8, causing a secondary access violation inside the unhandled crash reporter.crash::unwind_into,rsp + 8 > highoverflowed if a crashing thread corruptedRspnearu64::MAX, and(rsp as *const u64).read()caused aligned-read UB ifRspwas misaligned.Fix
p.len() >= 4, non-nullp[2]/p[3], non-zero RVAs, bounded non-zero catchable type count, non-nullp[1]forstd::exception, andread_unalignedinthrown.rsp.checked_add(8)andread_unalignedinunwind_into.Testing
thrown_and_unwind_handle_rethrow_and_corrupted_rspincrates/victory-loader/src/crash.rs.cargo test -p xtask --lockedpasses asset policy.@Marvisak on GitHub · 2026-11-25 18:37 UTC · original
Automated triage for the maintainers.
Hardens the crash reporter in
crates/victory-loader/src/crash.rs.thrownnow returns "unknown" for a C++ rethrow (throw;raises the MSVC exception with null object/ThrowInfo pointers, andmainreadp[2] + 12and faulted inside the reporter). It also returns "unknown" for zero RVAs or an empty type list, and skips thestd::exceptionmessage when the object pointer is null.unwind_intonow useschecked_addforrsp + 8; onmaina corruptedRspnearu64::MAXwrapped past the bounds check. It also reads the return address withread_unaligned, since a misalignedread()is UB and panics in debug builds. I checked the call site (report, which only requiresNumberParameters >= 4and the magic) and the loop exit onRip == 0. The new test's expectations ([0x1000],[0x2000]) match that code. Reporting only, with no change to emulation behaviour.CI: passing.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 00:52 UTC · original
Code review and Windows 11 verification at head
06cebbf704c7merged cleanly ontomain(63bcca43c6a0):crates/victory-loader/src/crash.rs:595-652, 754-796):thrownsafely rejectsp.len() < 4 || p[2] == 0 || p[3] == 0(covering C++throw;rethrows), checks RVA non-zero andp[3].checked_add(...), guardscount == 0, and reads integer/message values withp[1] != 0andread_unaligned().unwind_intopreventsu64::MAXwraparound viarsp.checked_add(8).is_none_or(|end| end > high)and usesread_unaligned()on the leaf (entry.is_null()) return-address read.RUNTIME_FUNCTION(!entry.is_null()), a misalignedcontext.Rspis still passed directly toRtlVirtualUnwind, and a few small fixed offsets insidethrown(p[2] + 12,types + 4 + 4 * i,descriptor + 16) still use plain+. Still a solid improvement overmain.cargo xtask policy:191 files ok;cargo clippy -p victory-loader --all-targets --locked -- -D warnings(default +--all-features): 0 warningscargo test -p victory-loader --locked: 36/36 unit + 4/4 integration passed;--all-features: 38/38 unit + 4/4 integration passed (includingthrown_and_unwind_handle_rethrow_and_corrupted_rsp).LGTM.
@futurepro62 on GitHub · 2026-11-26 01:35 UTC · original
NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head
06cebbf(on its base67e8ae1).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.thrown_and_unwind_handle_rethrow_and_corrupted_rsp.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@fuzeofficlal on GitHub · 2026-11-26 15:38 UTC · original · approved these changes
Reviewed
06cebbf704c71ff449fa81be05a90f0157c27b25(merged cleanly onto63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 acrossdev,--all-features, and--releasebuilds.Audit
crates/victory-loader/src/crash.rs:584,:585,:600):throw;rethrows (p.len() < 4 || p[2] == 0 || p[3] == 0), validates non-zerotypes_rva/entry_rva/desc_rvawithchecked_add, capscountat64and guardscount == 0, avoids dereferencing a null object pointer (p[1] == 0) forstd::exception, and usesread_unaligned()for raw pointer reads.crates/victory-loader/src/crash.rs:753,:762):rsp.checked_add(8).is_none_or(|end| end > high)closes theu64wraparound nearu64::MAXthat previously bypassed the upper stack bound, and(rsp as *const u64).read_unaligned()removes misaligned-read UB on corrupted leaf frames.Verification
63bcca43c6a00a758510398fa43096ce7e4f7df0+cargo run -p xtask -- policy(191 files ok)cargo clippy -p victory-loader --all-targets -- -D warnings(default &--all-features)cargo test -p victory-loader: 40/40 passed (dev), 42/42 passed (--all-features), 40/40 passed (--release), includingthrown_and_unwind_handle_rethrow_and_corrupted_rsp.p.len() < 4, nullp[2]/p[3], zerotypes_rva/entry_rva/desc_rva,count == 0andcount > 64, nullp[1]with.?AVexception@std@@, andunwind_intoatu64::MAX,u64::MAX - 7,u64::MAX - 6, andhigh - 7— all returned safely without faulting.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.