PE loader: load system DLLs by path as given and do not cache failures #1151
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1151
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1151"
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?
@emirduran707 on GitHub · 2026-11-24 12:34 UTC · original
emirduran707:resolver-system-cache→main· +47 −7 · 1 files · 1 commits · opensystem_modulecached host module handles inSYS_CACHEbydll_key, which drops the directory, and it cached failures (0) too. So:LoadLibrary("C:\Missing\foo.dll")failed, a laterLoadLibrary("foo.dll")returned NULL without trying;version.dllwas cached,LoadLibrary("C:\Mods\version.dll")returned the System32 copy.Windows loads the path it is given.
A name with a directory component is now loaded as given with
LoadLibraryWand is not cached. Bare names (import resolution, the HLE modules'system_module("x.dll")calls) still use the name-keyed cache, which now holds only successful loads.What is in it
crates/xcl/src/resolver.rs: the change, and testsfailed_system_load_by_path_is_not_cachedandsystem_load_by_path_loads_that_path.Tested
cargo test --workspace -- --test-threads=4on5157a51: 743 passed, 0 failed, 41 ignored; no SKIPPED GPU testsversion.dllis a Wine builtin, which Wine maps to the module already loaded under that name whatever the path;system_load_by_path_loads_that_pathchecks the load by path only on Windows (found in a test run under Wine, see the comments)Regression run
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code
system_module cached host module handles in SYS_CACHE keyed by dll_key, which drops the directory, and it cached failures (0) too. So after LoadLibrary("C:\Missing\foo.dll") failed, a later LoadLibrary("foo.dll") returned NULL without trying, and once version.dll was cached, LoadLibrary("C:\Mods\version.dll") returned the System32 copy. Windows loads the path it is given. A name with a directory component is now loaded as given with LoadLibraryW and not cached; bare names (import resolution, the HLE modules' system_module("x.dll") calls) still use the name-keyed cache, which now only holds successful loads. Under Wine, a copy of version.dll is a Wine builtin and is mapped to the module already loaded under that name whatever path is given, so the test checks the load by path only on Windows (found in a test run under Wine). Co-Authored-By: Claude Opus 5.5 <[email protected]>@DavidM1911 on GitHub · 2026-11-24 12:49 UTC · original
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug.
cargo test -p xcl --lib resolver: 7 passed, 0 failed — includes the newsystem_load_by_path_loads_that_pathandfailed_system_load_by_path_is_not_cached.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@emirduran707 on GitHub · 2026-11-24 14:10 UTC · original
Thanks @JoaoPauluu. Pushed
5157a51:system_load_by_path_loads_that_pathnow checks the load by path only whenutil::under_wine()is false, since Wine maps the builtinversion.dllto the loaded module whatever the path. On Wine it still checks that the load succeeds and that the bare name gives the System32 module. Reran the suite and the smoke run on5157a51(Windows) and updated the description. #1218 is rebased onto it (8200da8), also rerun.AI-assisted (Claude Code, Claude Opus 5.5).
@JoaoPauluu on GitHub · 2026-11-24 13:32 UTC · original · edited 2026-11-24 14:39 UTC
Rerun at
5157a51under Wine on Linux: allresolver::tests pass now.Tested
x86_64-pc-windows-gnu.5157a51as it is (based on47efa2e) andmain47efa2e, no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).resolver::tests on5157a51: 7 passed, 0 failed,failed_system_load_by_path_is_not_cachedandsystem_load_by_path_loads_that_pathincluded.eecffed:system_load_by_path_loads_that_pathfailed here atassert_ne!(h, sys)(both123145285140480). The prefix'sversion.dllis a Wine builtin (the file has theWine builtin DLLmarker), and Wine gave the System32 handle for the copy's path. With5157a51that check is skipped under Wine, so on Wine the by-path load itself is still not checked.scripts/linux/smoke.sh(#257) for 60 s, no input.Regression run
main:
this PR (
5157a51):Under Wine,
peak commitreads 0 MB, so these blocks do not check memory. The two runs are from the same morning, not back to back.Not tested
AI use
@emirduran707 on GitHub · 2026-11-24 19:32 UTC · original
@pvfreis No, I had not measured it. Measured now, on Windows 11 Pro 26300 with a Ryzen 5 5600:
LoadLibraryWthat fails costs about 0.50 ms per call here (2,000 calls of a name that exists nowhere; a name already loaded costs 1.7 µs).report.jsonlists one import from a DLL that is not on the PC (xmem.dll, stubbed) out of 1,186 imports. So the import pass pays about 0.5 ms more at startup.resolve_hlefallback lookups atresolver.rs:139go to the modules' fallback lists:kernelbase.dll,kernel32.dll,advapi32.dll,sechost.dll,xaudio2_9.dll,mfplat.dll,user32.dll, or the imported DLL's own name (SELF, skipped for the module's own name). Those load and are cached as before.GetProcAddresson a missing DLL in a loop: 0.5 ms per call. I have not seen one do that. If one does, a negative cache keyed by name, cleared whenever a load by path succeeds, would bring the old speed back without keeping a stale failure.Written with Claude Code (Claude Opus 5.5); the measurement is mine.
@luckyteagirl on GitHub · 2026-11-25 04:36 UTC · original
Native Windows resolver test report for PR #1151 at
5157a51c57a137f9500101d36b09a38e37a9329bSetup: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M (driver
30.0.13002.13003), Rust1.99.0MSVC. Clean checkout of the PR's exact head.Tested
cargo test --locked -p xcl --lib -j 2 resolver::tests -- --test-threads=1 --show-output: 7 passed, 0 failed, 0 ignored. Both new regressions passed: a failed load by path did not poison the later bare-name load, and an explicit path loaded the copiedversion.dllrather than the cached System32 module.cargo build --locked --workspace -j 2: passed.Not tested: Full workspace suite, a retail title that loads a DLL by full path, paired title smoke, or Wine. No game data was used.
AI assistance: OpenAI Codex (GPT-6) ran the commands, extracted the counts from the log, and drafted this report.
@DavidM1911 on GitHub · 2026-11-26 03:52 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@fromthemoonx on GitHub · 2026-11-24 12:51 UTC · original · edited 2026-11-26 04:17 UTC
Rerun on the new head
5157a51(system DLLs by path, failures not cached): still passes on the RTX 3060.cargo test --workspace --no-fail-fast -- --test-threads=4,5157a51merged ontomainb49be18(clean;resolver.rsauto-merged)SKIPPEDlinessystem_load_by_path_loads_that_pathandfailed_system_load_by_path_is_not_cached, alone, 30 runs each;resolver::(8 tests) at--test-threads=8, 30 runssystem_moduledisabled (if false && dll.contains(…))system_load_by_path_loads_that_pathfails (left != right, the cached System32 handle came back); the other 7 passSame machine, debug. The report below is for
eecffed.NVIDIA run with the whole suite, since Not tested lists NVIDIA.
Tested
stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debugeecffede46e7c3bab32a5af70cce6422d2f3d5f2, which is on currentmain47efa2e(so also the merged result):cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 743 passed, 0 failed, 41 ignored, the same as yoursresolver.rsas onmainplus only the two tests and theirmodule_pathhelper:failed_system_load_by_path_is_not_cachedpanics at line 624system_load_by_path_loads_that_pathfails itsassert_ne!at line 637resolver::+loader::tests, 10 runs: 10 of 10 passed (9 each)e2e, 3 runs: 3 of 3 passed. The test title resolves its imports and loadstestgame_mw.dllthrough this code.XCL_D3D12_DEBUG=1run logs the same set of debug-layer errors and warnings as onmain.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareNot tested
LoadLibrarys a mod DLL by path (none here); release build.AI use
@pvfreis on GitHub · 2026-11-24 14:17 UTC · original · reviewed
Review of
5157a51(merge base47efa2e), by reading the code; nothing was built or run here. I checkedsystem_module(resolver.rs:64-80) against its callers and that both new tests fail on the old code. No defect found.Question for the author: a bare name that fails is no longer cached, so for a DLL that is not on the PC each import of it (
resolver.rs:258) and eachresolve_hlefallback lookup (resolver.rs:139, also reached from the title'sGetProcAddress) runs a full failingLoadLibraryWsearch. Did you compare startup on a title that imports from such a DLL?Review by Claude Code (written by Claude Opus 5.5, second read by Claude Fable 5.2); each point checked by a person before posting.
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.