Loader/HLE: run the process-detach notices when a title calls ExitProcess #837
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!837
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-837"
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?
@CwWwWwW on GitHub · 2026-11-28 07:34 UTC · original
CwWwWwW:fix/exitprocess-detach-v2→main· +59 −2 · 4 files · 1 commits · merged 2026-11-29 08:16 UTCPorted to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1445 (head
f8fb88249b, author CwWwWwW). The fork's own line was dropped when it rebased onto959dcaf(5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main63b902f.Problem
A title's
ExitProcessimport was bound to the host'sExitProcess, which ends the process without the loader's process-detach path. Title images are prepared with no entry point and no TLS callbacks, so the only way a title DLL hearsDLL_PROCESS_DETACH(and its CRTatexit/flush/static destructors, and the exe'sPROCESS_DETACHTLS notice) isvictory_loader::threads::detach_all, registered on the host CRT'satexit. The hostExitProcessdoes not run CRTatexit: a normal exit path silently skipped every detach notice - a data-loss risk for anything flushed or released there.Fix
victory-loader: makedetach_allidempotent (anEXITINGswap guard) and export it asthreads::exit_notices.victory-hle: exportExitProcessfromkernel32,kernelbaseandapi-ms-win-core-processthreads; the override logs, runsexit_notices, then calls the hostExitProcess.TerminateProcessis unchanged (Windows sends no DLL notifications for it).Tests and evidence
tests::exit_process_resolves_to_our_exportclassifiesExitProcessasHlefor the three DLLs; it fails before the change (Host).DllMainmarker and an export calling its importedExitProcess; before:attach, quit-called, after:attach, quit-called, detach.cargo test -p victory-hle --lib --locked: 104 passed;-p victory-loader --lib --locked: 28 passed; clippy clean for both.Implemented independently from the target tree; no external code was copied. Based on main 9a9091d - it supersedes the old branch
fix/exitprocess-detach, which was made on 4245f3.The PR's Clippy check fails on main already: at 9a9091d
cargo clippy --workspace --all-targetsfails invictory-shader(wave64_after_loop.rs precedence, valu_tests.rs simplifiable/negated partial-ord comparisons); open PR #1440 fixes exactly those lints. This diff touches none of those files, and the touched crate's own tests and clippy are clean locally.Verification on this tree (base
63b902f, 2026-11-27)63b902ffailed on those before this change.Hardware verification suggested
@Dukestar69 on GitHub · 2026-11-28 07:48 UTC · original · approved these changes
Tested locally merged onto
main(63b902f).cargo xtask policypassed (294 files ok).cargo test -p victory-loader --libpassed (45 passed; 0 failed, includingthreads::tests::exit_ends_the_other_threads_firstandthreads::tests::exit_child).cargo test -p victory-hle --lib processpassed (2 passed; 0 failed, including the newtests::exit_process_resolves_to_our_exporttest).Clean process-detach lifecycle wiring on
ExitProcess. LGTM.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).