Repository navigation
Conversation
…2-bit IR length Fix three FFI safety bugs in crates/xcl/src/gpu/recomp/dxil/assemble.rs: 1. Guard empty and null DXC blob pointers via blob_bytes() before calling std::slice::from_raw_parts() in errors() and assemble(), trimming trailing NULs, falling back to the failed HRESULT when the error buffer is empty, and rejecting an empty validated DXIL container. 2. Check for a null COM out-pointer in make<T>() after DxcCreateInstance returns S_OK before calling T::from_raw(p). 3. Check ir.len() with u32::try_from() via blob_len() instead of silently truncating via `ir.len() as u32` before calling IDxcUtils::CreateBlob. Part of xcl-dev#2413 Part of xcl-dev#1833 Part of xcl-dev#1269 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
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
On both cards, the only result changes against Not tested: the D3D12 debug-layer tests (no |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
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