Repository navigation
DXC: unload a candidate folder that is not a usable dxcompiler (#2413) - #2643
kotekompotek wants to merge 1 commit into
Conversation
…ev#2413) load() kept a candidate's dxil.dll (and dxcompiler.dll when it loaded but lacked DxcCreateInstance) mapped for the rest of the process when the candidate was skipped: the h.is_null() and GetProcAddress-miss paths both fell through without FreeLibrary. A stale dxil.dll in the loaded-module list is the one a later candidate's dxcompiler.dll binds by name. The per-folder attempt is try_dir now and frees both handles before moving on; a mapped file refuses deletion on Windows, so the test reads the leak back through the filesystem.
|
The three GPU tests listed as not tested (they fail on the GTX 1050, which has SM 6.5 at most) pass with this PR on two SM 6.6 cards, an RX 9070 XT and an RTX 3060. The 2 new tests pass too. Head
Not tested: the whole suite with this PR, a title. |
|
Test report: passes on NVIDIA, and both new tests fail without the unloads. Exact head Tested
Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
luckyteagirl
left a comment
There was a problem hiding this comment.
At exact head 5371d1df on current main b49be18, one “unusable candidate” path still retains the early DLL and prevents a later working folder from being tried. This is a source-derived review; I did not build a fake DXC DLL.
try_dir accepts and caches a candidate as soon as dxcompiler.dll exports DxcCreateInstance. Its library() call probes version info but explicitly treats that probe's failure as nonfatal. The interface XCL actually needs is CLSID_DxcCompiler / IDxcCompiler3, requested only later in compiler(). A DLL with the export that returns E_NOINTERFACE (or a null pointer) for that interface is therefore published in LIB; every compile then fails, while a later usable DXC candidate is never visited. The early dxil.dll also stays mapped. The new unload tests cover a missing DLL and a missing export, but not an export that cannot create the required interface.
Could try_dir probe IDxcCompiler3 before publishing the candidate, release the probe object, and unload both handles on failure? An injected export that fails this IID followed by a good candidate would cover selection and cleanup.
AI assistance: GPT-6.2 Sol found the missing interface check; GPT-6.2 Astra verified the exact-head loader and compiler paths.
load()scans candidate folders for a usable DXC: it loadsdxil.dll(the signer) anddxcompiler.dll, and keeps the first folder whosedxcompiler.dllexportsDxcCreateInstance. Whendxcompiler.dllfailed to load, or loaded without the entry point,load()moved on withoutFreeLibrary– the failed folder'sdxil.dll(anddxcompiler.dll) stayed mapped for the rest of the process. A staledxil.dllin the loaded-module list is the one a later candidate'sdxcompiler.dllbinds by name when it loads its owndxildependency, so a bad early folder poisons the later good one. Fixes #2413 (the candidate-load half; the empty-blob half is #2580).What is in it
gpu/recomp/dxc.rs: the per-folder attempt istry_dirnow and frees both handles before moving on (opus.rsuses the sameFreeLibrarypattern).candidate_unload_tests: a mapped file refuses deletion on Windows, so each test copies a stand-in DLL into a temp candidate folder, runstry_dir, and deletes the files – a leaked module keeps its file locked. One test covers thedxcompiler.dll-won't-load path, the other the missing-DxcCreateInstancepath; both fail before the fix (PermissionDenied).Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on the head5371d1df: 1434 passed, 3 failed, 47 ignored (SKIPPED GPU tests: 357 – this adapter has no SM 6.6 / mesh shaders)cargo test -p xcl --lib candidate_unload: 2 passedHRESULT/0x80070057, no SM 6.6 PSOs); details in the Not tested sectionRegression run (0 s, default settings, a retail title)
main:
this PR:
Not tested
hle::d3d12x::vram::tests::gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark,shaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_cap,shaders::pipeline_cap_tests::split_compute_program_prebuilds_and_caches_chain_pieces: fail onmainidentically (GTX 1050 is SM 6.5 max; driver answers0x80070057).-Seconds 0produces a clean run; frames shown is 0 in both blocks.peak commitreads either ~900 MB (title killed during DLL loading) or ~5.4 GB (title reached its GDK heap reservation) depending on kill-vs-init timing under load; both blocks here are the ~900 MB outcome of otherwise identical runs.AI use