Repository navigation
DXC: an empty blob's null buffer is an empty slice, not UB (#2413) - #2580
kotekompotek wants to merge 1 commit into
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
Integrates upstream amd-dev 9f02a3b (BVH null/OOB guard), b67375b (scratch SADDR 0x7F), 4ae5668/xcl-dev#2565 (32-bit VALU add/sub carry without i64), plus open PRs xcl-dev#2559 (bfm/ffbh_i), xcl-dev#2557 (known_nonzero_bits folding), xcl-dev#2552 (f16-to-f32 fold), xcl-dev#2568 (integer min/max range opt), and xcl-dev#2580 (empty DXC blob null slice). Assisted-by: Antigravity (Gemini 4 Neon)
) compile_here reads IDxcBlob contents with slice::from_raw_parts(ptr, len); an empty IDxcBlob reports a null GetBufferPointer, and from_raw_parts on a null pointer is UB even at length 0 (debug builds abort on it) – an empty error buffer would panic inside the error-reporting path itself. blob_bytes maps a null pointer to an empty slice at both the error-buffer and result reads.
|
Two contributors checked independently and found that this PR makes the same change as #2441 (for #2413): #1607, group D123. They suggest keeping #2441. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
c7eb111 to
750e9d3
Compare
|
Closing per the D123 dedupe in #1607 — this makes the same fix as #2441 (both return an empty slice for an empty blob's null buffer pointer instead of the UB |
Fixes #2413 (the empty-blob half; the candidate-load handle leak is a separate PR).
DXC results are read out of
IDxcBlobs withslice::from_raw_parts(ptr, len)(output(), shared bycompile_whole,compile_linkedanddisassemble). An emptyIDxcBlobreports a nullGetBufferPointer, andfrom_raw_partson a null pointer is UB even at length 0 – debug builds abort on the non-null precondition, so an empty error buffer would panic inside the error-reporting path itself (and an empty result blob on the success path).What is in it
gpu/recomp/dxc.rs: ablob_bytes(ptr, len)helper maps a null pointer to an empty slice; both reads (theGetErrorBuffertext and theGetResultDXIL) go through it.blob_bytes_tests:a_null_blob_buffer_is_an_empty_slicecovers the null-pointer and ordinary-buffer cases. (The samefrom_raw_parts(blob…)shape exists in a few other files – mentioned, not changed: this PR is scoped to the DXC compile path the issue names.)Tested
cargo test --workspace --no-fail-fast -- --test-threads=4: 1421 passed, 3 failed, 46 ignored (SKIPPED GPU tests: 355 – this adapter has no SM 6.6 / mesh shaders); run onc7eb111, the same diff before the branch was rebased ontob49be183to resolve a collision with the new DXC linking code750e9d30:cargo test -p xcl --lib: 1303 passed, 3 failed, 27 ignored (4 timing-sensitive tests flaked under parallel release builds; all 4 passed in a targeted rerun)gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark(driver refuses a sparse heap op, HRESULT 0x80070057),stale_blob_cannot_bypass_the_offline_pipeline_capandsplit_compute_program_prebuilds_and_caches_chain_pieces(both build/dispatch cs_6_6, which this SM 6.5 adapter cannot run)a_null_blob_buffer_is_an_empty_slicepasses; the pre-fix shape (from_raw_partson the raw pointer) cannot be exercised through it – the UB is on the DXC edge case itselfRegression run
main:
PR:
Not tested
XCL_RUN_SECONDS=0before that point – they cover host boot, game loading and shutdown, no frames, no shaders.blob_bytesunit level; DXC blobs cannot be stubbed without a COM double.AI use
blob_byteshelper, the unit test, the test suite, both smoke runs and this PR.