Loader: fix thread shutdown targeting, registry lifetime, and CRT detach ordering #1304
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!1304
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1304"
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?
@geiyiliyabumo on GitHub · 2026-11-24 17:17 UTC · original
geiyiliyabumo:test/loader-threads-audit→main· +498 −156 · 2 files · 1 commits · openSummary
Audits \crates/victory-loader/src/threads.rs\ (with a minimal companion registration call in \windows.rs) and fixes real lifecycle/shutdown bugs:
Verification
AI-assisted; synthetic tests only, no game files.
@Marvisak on GitHub · 2026-11-25 02:34 UTC · original
Automated triage for the maintainers.
This PR rewrites most of
crates/victory-loader/src/threads.rsand bundles several separate changes: earlieratexitregistration (register_process_detach, called fromLoadedImage::attachandspawn_main), load reference counting inmapped/unmapped, atomic per-image notice state, a reworkedend_other_threads/end_thread, andMaybeUninitTLS snapshots. The registration-order point is plausible: on main,attached()registersdetach_allonly after the firstDllMainreturns, so a handler the title registers with the host CRT during that attach runs after ours. But the bundle also changes exit behaviour.end_other_threadsnow returnsErrwhenOpenThreadfails for any reason other thanERROR_INVALID_PARAMETER(for example access denied), when the start address cannot be read on a live thread, or when the snapshot is short.detach_allthen callsend_process(), which skips every titleDLL_PROCESS_DETACH. On main, such threads are skipped and detach still runs. AfterTerminateThreadthe code also waits withINFINITEand relies on the watchdog.To move this forward, please split it: the
atexitordering fix as a small PR of its own, and the thread-ending and registry changes separately, each with a short note on the failure it fixes. Please also say whether title images actually register exit handlers in the host CRT's table rather than in their own (the new test assumes they do). No CI ran on this head.Generated by Claude Code
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.