PE loader: load system DLLs by path as given and do not cache failures #1142
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T12:34:37Z.
system_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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:49:27Z.
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.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-24T12:51:40Z.
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
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T13:32:59Z.
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
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T14:17:52Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T14:10:51Z.
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).
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T19:32:08Z.
@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.
upstream-sync referenced this pull request2026-11-25 00:07:29 +00:00
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T04:36:12Z.
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.
upstream-sync referenced this pull request2026-11-25 23:07:28 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:52:35Z.
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
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T20:21:15Z.
merge-check
base:
6089122a1chead:
5157a51c57merge: clean
build:
cargo build --workspace-> oktests:
XCL_ADAPTER=nvidia cargo test --workspace --no-fail-fast -- --test-threads=4-> 1466 passed, 1 failed, 47 ignored; 25SKIPPEDnotices. Both newresolver::testspassed. The sole failure wasgpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(DXIL not compiled), also reproduced on untouchedmainat this base here.review: No introduced runtime blocker found in the full diff. Explicit paths now reach
LoadLibraryWas supplied, and each such call gets its own module reference that the title'sFreeLibrarycan release. Successful bare-name loads retain the existing cache; failures are no longer stored. The two new tests establish path bypass, but neither would fail if bare-name failures were cached again. A separate isolated-process regression could fail a unique bare-name lookup, make that DLL loadable, then retry and resolve an export. The copiedversion.dllin the path test is also left in its temporary directory after the test process exits. These are test-hygiene and coverage follow-ups, not an observed runtime failure in this change.performance: No added work on successful cached bare-name lookups. Explicit path loads and failed bare-name probes now call the Windows loader on each attempt; their frequency and timing in a title were not measured.
verdict: safe to merge
hardware / tool and model: NVIDIA RTX 3080 Ti 12 GiB, driver 621.35; Ryzen 7 9800X3D; Windows 11 build 26300; rustc 1.99.1 MSVC; DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the build and tests, reviewed the diff and drafted this check; Codex (GPT-6.2 Astra) independently reviewed loader ownership and test coverage.
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:32:14Z.
merge-check claim
head:
5157a51c57Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:52:23Z.
merge-check
base:
6089122ahead:
5157a51c57merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: no blocker. The name comes from the title through the LoadLibrary shims; main already passed a full path to LoadLibraryW on the first load of each base name, so no new kind of load: what changes is that a title's own copy of a DLL no longer replaces the cached system handle XCL itself uses, and a path can be loaded again after a failure. The title runs native code in this process anyway, so no boundary is crossed.
performance: failed loads are no longer cached: each failing bare name costs a full search (about 0.5 ms by the author's measurement); import resolution at start and the GetProcAddress fallback, not per frame unless a title polls (not measured).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).