Run, HLE: keep late-loaded title DLLs private until DllMain succeeds and unload on bind failure #2447
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!2447
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2447"
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?
@fuzeofficlal on GitHub · 2026-11-29 13:07 UTC · original
fuzeofficlal:fix/late-dll-publish-and-bind-rollback→main· +661 −31 · 2 files · 1 commits · merged 2026-11-30 14:12 UTCSummary
Fixes two lifecycle and concurrency bugs in late title DLL loading (
LateDlls::loadinapps/victory/src/run.rsandIMAGE_PATHSincrates/victory-hle/src/runtime.rs):Prevent cross-thread observation and use-after-free of uninitialized/rolling-back DLLs:
Previously,
LateDlls::loadregistered every newly mapped DLL globally inIMAGE_PATHSviaset_image_pathbefore runningDllMain(DLL_PROCESS_ATTACH). BecauseGetModuleHandleA/W,GetModuleFileNameA/W, andimage_containingqueryIMAGE_PATHSwithout acquiringLoaderLock, another thread could observe anHMODULEwhileDllMainwas still executing on the loading thread—either invoking exports before initialization finished, or holding a dangling module handle / reading unmapped headers whenDllMainreturnedFALSEandLateDlls::loaddetached and unmapped the batch viadll.unload().victory_hle::runtimenow supports thread-staged image paths (stage_image_path/publish_images). Staged images remain visible to the loading thread (soDllMain,GetModuleFileName,GetModuleHandle,FreeLibrary,image_containing, and re-entrantLoadLibrarycontinue to work during both attach and rollback detach), stay hidden from all other threads until every DLL in the batch finishesattach(), and are published atomically as a batch beforeLoaderLockis released.Roll back mapped DLLs on import-binding failure:
Previously, if
bind_importsfailed on a later DLL in a newly mapped batch, early?exit leaked every mappedLoadedImagein host virtual memory andvictory_loader::threads::IMAGESwhile leaving earlier bound DLLs permanently registered inIMAGE_PATHSwithout ever running theirDllMainor adding them toLateDlls::mapped.LateDlls::loadnow completes import binding for the entire batch before staging paths or updatingmapped, and unloads every newly mapped image in reverse order if binding fails.Verification
System32\version.dllwith unique trailing overlay tags andBarriersynchronization inapps/victory/src/run.rs(late_dll_*) andcrates/victory-hle/src/runtime.rs(staged_images_are_thread_private_until_published_or_forgotten).VIctory-NVIDIA:cargo test --locked -p victory late_dll_cargo test --locked -p victorycargo test --locked -p victory-hle -- --test-threads=1cargo clippy --locked -p victory -p victory-hle --all-targets(no new warnings)cargo run --quiet --locked -p xtask -- policy --staged