DXIL assemble: guard null/empty DXC blobs, null COM interfaces, and 32-bit IR length #2577
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2587"
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 Decodere on 2026-11-26T00:29:04Z.
Fixes three DXC FFI safety bugs in
crates/xcl/src/gpu/recomp/dxil/assemble.rs: empty/null DXC blobslice::from_raw_partsUB inerrors()andassemble(), missing null COM interface pointer check inmake<T>(), and silent 32-bit IR length truncation viair.len() as u32. Part of #2413, Part of #1833, Part of #1269.What is in it
crates/xcl/src/gpu/recomp/dxil/assemble.rs(blob_bytes,errors,assemble): factorblob_bytes(ptr, len)returningOk(&[])whenlen == 0(never callingslice::from_raw_partson null),Err("null DXC blob buffer")whenptr.is_null() && len > 0, andOk(slice)otherwise; trim trailing\0bytes inerrors()and fall back to formatting the failedHRESULTwhen the error buffer is missing, empty, or whitespace-only; reject an empty validated container inassemble()with"assemble: empty DXIL container".crates/xcl/src/gpu/recomp/dxil/assemble.rs(make): checkif p.is_null()afterDxcCreateInstancereturnsS_OKbefore callingT::from_raw(p), returningErr("DxcCreateInstance: returned null interface").crates/xcl/src/gpu/recomp/dxil/assemble.rs(blob_len,assemble): validateir.len()withu32::try_from(len)instead of truncating viair.len() as u32before callingIDxcUtils::CreateBlob.crates/xcl/src/gpu/recomp/dxil/assemble.rs(mod tests): added 3 pure-CPU / mock-COM0-skip unit tests (blob_bytes_and_blob_len_validate_null_empty_and_bounds,make_rejects_null_interface_and_propagates_hresult, anderrors_handles_null_empty_blob_trims_nuls_and_falls_back_to_hresult) alongside preservedir_text_assembles_signs_and_runs.Tested
rustc 1.100.0, DXC1.9.2609.5,--release.08db8020:make_rejects_null_interface_and_propagates_hresultaborted with0xc000001d(STATUS_ILLEGAL_INSTRUCTION) insideIUnknown::from_raw(null)before the null-pointer guard was added.cargo test --release -p xcl --lib -- gpu::recomp::dxil::assemble::tests:: --nocapture:4 passed, 0 failed, 0 ignored,0skips on both RTX 4060 and WARP (XCL_ADAPTER=warp,XCL_WARP=1).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture:37test binaries,1432 passed, 0 failed, 47 ignored(SKIPPED GPU/host tests: 29 pre-existing on 32-lane RTX 4060 without D3D12 debug layer — 21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped ingpu::recomp::dxil::assemble::tests).Regression run
main:
PR:
Not tested
CreateBloballocation (covered viablob_len((u32::MAX as usize) + 1)unit check).AI use
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-26T00:41:43Z.
Full-suite run, since this PR has no test report yet. Tested exact head
534deb25(on its base08db802).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1420 passed, 0 failed, 45 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.blob_bytes_and_blob_len_validate_null_empty_and_bounds,make_rejects_null_interface_and_propagates_hresult,errors_handles_null_empty_blob_trims_nuls_and_falls_back_to_hresult.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1431 passed, 0 failed, 47 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main08db8020too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T00:52:59Z.
64-lane AMD run (listed as untested; the report above is NVIDIA): the 3 new tests pass, and nothing else changes in the GPU suite on an RX 9070 XT or an RTX 3060.
Head
534deb2applied onmainb49be18, debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR, card chosen withXCL_ADAPTER:mainOn both cards, the only result changes against
mainare the newblob_bytes_and_blob_len_validate_null_empty_and_bounds,errors_handles_null_empty_blob_trims_nuls_and_falls_back_to_hresultandmake_rejects_null_interface_and_propagates_hresult, all ok, with no new skips. So the wave64 GPU tests that skip on a 32-lane GPU ran with this PR on the RX 9070 XT and still pass. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: the D3D12 debug-layer tests (no
d3d12SDKLayers.dllhere either), Intel, a title.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:09:46Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T16:26:45Z.
merge-check claim
head:
534deb254fImported from ivall/xcl. Originally posted by throny on 2026-11-28T16:48:39Z.
merge-check
base:
db3921dchead:
534deb254fmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2148 passed, 0 failed, 48 ignored (26 SKIPPED lines). Base alone at
db3921dc: 2145 passed, 0 failed, 48 ignored.review: no blocking finding; all hunks read. Nothing that was reported before is hidden now: an empty error buffer gives the HRESULT instead of an empty message. One behaviour change to know: an empty DXIL container is now an error where main returned an empty result; I did not trace what every caller did with the empty result. Not verified: that the bindings turn a null interface out-pointer into an error for every call used here.
performance: none. The file is not in the translator source lists: no re-translation.
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).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T22:03:22Z.
merge-check
base:
7db2f391ce(7db2f391)head:
534deb254f(534deb25)merge: clean; one file, +116/-8 against its parent;
git diff --checkpassed.build:
cargo build --offline --locked -j 4 --workspacepassed on the merged tree.tests:
cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4on the merged tree: 2,596 passed, 1 failed, 49 ignored, with 26 explicitSKIPPEDnotices. Untouched base with the same command: 2,593 passed, 1 failed, 49 ignored, with the same 26 skips. Both complete runs failed onlygpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(DXIL not compiled yet). The three newassembletests passed on the PR tree. A separate PR run produced four additional pipeline-library/warm-library failures and two two-pass-cache integration failures; an earlier base run aborted in a parallel PSO thread before its library-test summary. These extra results were not stable across reruns, and I cannot attribute them to this PR.review: no blocking source finding. The only in-tree
assemblecaller requires a nonemptyDXBCresult or an error, so rejecting an empty container preserves its contract. The locked Windows bindings reject null COM out-pointers fromCreateBlob,AssembleToContainer,GetResult,GetErrorBuffer, andValidate; the three rawDxcCreateInstancecalls now check both HRESULT and pointer before taking ownership. The blob slices are consumed while their COM owners are alive.performance: not measured; the change is in DXIL assembly error handling.
verdict: safe to merge for the reviewed change, subject to the repository's CI and maintainer batch run. The workspace suite is not green on either tested tree because of the shared mesh-cache failure.
hardware / tool and model: Windows 11 build 26300; RTX 3080 Ti, driver 621.35; Ryzen 7 9800X3D; rustc 1.99.1 MSVC; DXC 1.8.2502.11; debug. Codex (GPT-6.2 Sol) ran the merge, build, tests and source review; Codex (GPT-6.2 Astra) independently traced the FFI and caller boundaries.