App: release LoaderLock on unwind via Drop guard #3001
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!3001
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3001"
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?
@Dukestar69 on GitHub · 2026-11-26 03:01 UTC · original
Dukestar69:fix/loader-lock-unwind→main· +38 −10 · 1 files · 1 commits · closed without mergingProblem
In
apps/victory/src/run.rs,LoaderLock::holddecrements the re-entrancy counter, clearsowner, and callsself.free.notify_one()only on the normal return path afterf(). Iff()panics/unwinds, the lock remains owned by the panicked thread indefinitely, causing any other thread callingLoaderLock::holdto deadlock inself.free.wait(...).Fix
Move the release logic into a local RAII
Guard(impl Drop) created immediately after acquiringself.owner, so both normal returns and unwinds (including re-entrant holds) decrement the count and notify waiters when it reaches zero.Verification (Windows 11 x64)
cargo test -p victory --bin victory run::: 8 passed, 0 failed (including newloader_lock_releases_on_panic_and_reentrant_unwind, which times out/deadlocks onorigin/main63bcca4).cargo clippy -p victory --all-targets -- -D warnings: clean.rustfmt --edition 2024 --check apps/victory/src/run.rs: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@futurepro62 on GitHub · 2026-11-26 04:40 UTC · original
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
8603102(on its base63bcca4).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: 867 passed, 0 failed, 10 ignored.loader_lock_releases_on_panic_and_reentrant_unwind.--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
@Marvisak on GitHub · 2026-11-26 05:34 UTC · original
Automated triage for the maintainers.
Proposed close. The change makes
LoaderLock::holdinapps/victory/src/run.rsrelease the lock while unwinding. The deadlock it prevents cannot happen in this program. The only caller isLateDlls::load, which is reached only through the title-DLL loader closure. That closure runs fromvictory_hle::runtime::load_title_dll, called byfind_moduleinvictory-hle/src/modules/kernel.rsunder theextern "system"exportsLoadLibraryExA/ExW/A/W. A Rust panic cannot unwind out of anextern "system"function: the process aborts. So no other thread is left waiting on the lock. The new test only shows the unwinding case because it callsholddirectly on a test thread.It would be worth reopening if there is a caller that catches the unwind (for example a
catch_unwindaround the loader closure). This PR has no CI run.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 06:45 UTC · original
Fair point from triage — since LateDlls::load is only reached through extern system LoadLibrary* exports, a Rust panic aborts the process rather than unwinding. Closing to keep the queue clean. AI-assisted (Gemini 4 Neon).
Pull request closed