D3D12.X: guard truncated, null, and unreadable mesh pipeline streams #2015
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2015
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2015/head"
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?
@GustavoEllwanger on GitHub · 2026-11-25 00:46 UTC · original
GustavoEllwanger:fix/mesh-stream-bounds-and-null-guard→main· +394 −11 · 2 files · 1 commits · merged 2026-11-25 10:41 UTCRelated to #1968 and #1833 (hardens the mesh pipeline stream path audited for #1968; does not claim to resolve the unconfirmed
ntdll.dll+0x1ff2acrash from #1968's local build).What is in it
Fixes three concrete memory-safety / panic gaps in the
CreatePipelineStatemesh-stream path (crates/xcl/src/hle/d3d12x/real.rs), plus unit and GPU integration tests that run on any D3D12 adapter (AMD, NVIDIA, Intel, or WARP):own_stream: checkreadable(desc, 16)before dereferencingdesc; checkat + psize <= sizebefore indexing subobject payloads (previously panicked on truncated tail subobjects); clear zero-length shader entries and returnNonewhen a non-null, non-empty shader pointer is unreadable instead of handing a dangling title pointer to the background PSO worker.finish_two_pass: checkppv.is_null() || (*ppv).is_null()right afterfinish_psosucceeds, returningE_INVALIDARGbefore compiling the compute pass or dereferencing*ppvduring error cleanup / registration.dev_create_pipeline_state: guard the directfinish_psofallback withstream_has_unreadable_shader(desc)so a stream carrying an unreadable shader bytecode pointer returnsE_INVALIDARGinstead of access-violating (0xC0000005) insideD3D12Core.dll.mesh_stream_testsinreal.rsandcrates/xcl/tests/d3d12_mesh_stream.rs): cover null/truncated/unreadable streams inown_stream, null out-pointer handling infinish_two_pass, console MS in the AS slot (E_INVALIDARG), console MS + AS together, malformed/unreadable streams throughID3D12Device2::CreatePipelineState, and 5-thread concurrent stream refusals.Regression run
Paired 60 s retail-title runs on Windows 11 Pro 26300 / NVIDIA GeForce RTX 5070 Ti (driver 621.24, release build) contributed by @Royalflamejlh in #2015:
Tested
cargo test -p xcl --lib mesh_stream_tests -- --nocapture: 2 passed, 0 failed, 0 ignored.cargo test -p xcl --test d3d12_mesh_stream -- --nocapture: 3 passed, 0 failed, 0 ignored (RX 7600).XCL_ADAPTER=warp cargo test -p xcl --test d3d12_mesh_stream -- --nocapture: 3 passed, 0 failed, 0 ignored (WARP).XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e heap_window_out_of_memory_falls_back_to_the_switch_form -- --nocapture: 1 passed, 0 failed (RX 7600).cargo test --workspace --no-fail-fast -- --test-threads=4 --skip fuzz_validate_and_gpu_1: 997 passed, 0 failed, 45 ignored, 1 filtered out, 0 wave64/mesh capability skips (8SKIPPEDlines: 6 per-lane#1426refusals, 1 driver cache / no Windows Developer Mode, 1no heap windowsverified separately above).XCL_ADAPTER=warp cargo test -p xcl --lib fuzz_validate_and_gpu_1 -- --nocapture: 1 passed (validated 500/500 modules500..1000,GPU-compared 0).git diff --check: passed.1633vs1633frames on Windows,1363vs1575frames on Linux, 0 crashes / 0 device removals).XCL_PSO_PRELOAD=0,Aat 16 s): 0 failed pipelines / 0 faults / 0 device removals.--lib mesh_stream_tests2 passed,--test d3d12_mesh_stream3 passed.cargo test -p xcl --lib(merged with currentmain): all passed, 0 failed (~26 ignored).Not tested
XCL_SAMPLE_*game-data tests, or a retail title actually triggering a truncated stream / unreadable shader at runtime.AI use
Written and verified with Antigravity (Gemini 4 Neon); all AMD RX 7600 and WARP builds and tests were run locally on this machine. NVIDIA / retail smoke runs were contributed by @Royalflamejlh and @DavidM1911 as linked above.
@raylitebull on GitHub · 2026-11-25 01:25 UTC · original
Code review on
3705368:own_streamincrates/xcl/src/hle/d3d12x/real.rscleanly validates descriptor/stream readability, useschecked_addfor subobject offsets/sizes, zeroes stale pointers whenp == 0 || n == 0, and fails closed when a non-empty shader pointer is unreadable.finish_two_passchecksppv.is_null() || (*ppv).is_null()before entering the compute pass, andstream_has_unreadable_shaderavoids handing invalid bytecode pointers to D3D12Core.mesh_stream_testsandcrates/xcl/tests/d3d12_mesh_stream.rscover empty/truncated/unknown/unreadable streams and concurrent refusals cleanly.CIworkflow approved (currently running).Remaining before merge:
PR descriptioncheck.Build and test (Windows, no GPU)finishes green.3705368.@GustavoEllwanger on GitHub · 2026-11-25 01:40 UTC · original
Thanks for the review @raylitebull!
Build and test (Windows, no GPU)has finished green.3705368are already listed under Tested in the PR description (mesh_stream_tests2/2,d3d12_mesh_stream3/3, full suite997 passed, 0 failed).3705368and share the pairedxcl-smoke v1blocks (main+3705368), I'll add them to the PR description right away.@Royalflamejlh on GitHub · 2026-11-25 03:45 UTC · original
NVIDIA test of
3705368with a retail title, as asked above, on native Windows and on Linux (Wine + vkd3d-proton);80f4819is the commit ofmainit branches from. No run crashed or lost the device.Setup: Windows: Windows 11 Pro 26300, RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, 32 GB RAM, rustc 1.99.1, release. Linux: Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, RTX 4070 12 GB (driver 615.71.09); release, cross-compiled to
x86_64-pc-windows-gnu(rustc 1.98.0). Retail title 1.0.2.1, the first-run screens completed once and no story progress.Regression run (
scripts/smoke.ps1, unchanged, 60 s, start screen; one run each)Windows (the run of
3705368was made first),mainand then this pull request:Linux, the same two commits (
mainran first): 1363 frames on80f4819and 1575 on3705368, 0 device removals and 0 crashes on both; each ran beside a title run on the machine's second card (the end of one, then the start of the next).Tested
XCL_PSO_PRELOAD=0main2bdf047+ #6843705368mainbeside the middle of the same run.--lib mesh_stream_tests2 passed,--test d3d12_mesh_stream3 passed.Read
real.rs:5575: a stream with an unreadable shader now returnsE_INVALIDARGbeforefinish_psoandnote_fallback, so nothing is logged or counted. The run with the change cannot show whether the title sent one. Would anxlog_warn!there be worth it?Not tested: a truncated stream or an unreadable shader in a title run; the tests, and the title past the start screen, on Windows; the rest of the suite; AMD and Intel; past 100 s.
AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the title, the regression pairs and the tests, and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
@DavidM1911 on GitHub · 2026-11-25 04:01 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@GustavoEllwanger on GitHub · 2026-11-25 04:06 UTC · original
Huge thanks @Royalflamejlh and @DavidM1911 for running the NVIDIA and retail smoke verifications on
3705368!I've added the paired
xcl-smoke v1blocks and NVIDIA results to the PR description and marked this ready for review.Regarding the logging question at
real.rs:5575:capture_stream_desc(desc as *const u8)already runs on the first line ofdev_create_pipeline_stateand callsgpu::shader::capture(), which incrementsstats.rejected_pointers(inreport.json) and emitsxlog_warn!("[SHADER] {stage}: invalid pointer/size ({ptr:#x}, {len}) – different struct layout on the console?")(crates/xcl/src/gpu/shader.rs:273-278), so an unreadable shader pointer in a stream is already logged and counted. Leaving3705368unchanged also keeps the paired smoke blocks valid without needing a rerun.