Repository navigation
Conversation
The path that puts a call off to a segment of its own, recorded at the submit (xcl-dev#2118), ignored the native Close result twice: deferred_segment added the new empty segment to the recording whatever its Close returned, and record_deferred closed the segment after recording the call, ignored the result and chained the next segment to it. A segment whose recording the runtime refused was submitted with the rest: in a test, submitting one removed the device (0x887A0001, an invalid call). Found by KOLESNiii in a static review on xcl-dev#2088. A put-off segment that does not close when it is made is not used: it goes back to the spares and the call waits in its list, as before xcl-dev#2118. One that does not close after its call is recorded leaves the recording (a list whose Close failed is still open and cannot be reset), its call is dropped and counted, and the next one does not follow it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
luckyteagirl
left a comment
There was a problem hiding this comment.
Source-derived adapter selection finding, supported by a local D3D12 null-device LUID probe. No PR test run.
| use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0; | ||
| use windows::Win32::Graphics::Dxgi::*; | ||
| let mut dev: Option<ID3D12Device> = None; | ||
| if D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).is_err() { |
There was a problem hiding this comment.
The two requested AMD RDNA2 tests call D3D12CreateDevice(None, ...), so XCL_ADAPTER=6800M does not select their device. On this hybrid AMD laptop, a standalone call with the same arguments succeeded and its device LUID matched the integrated AMD Radeon(TM) Graphics (DEV_1638), not the RX 6800M (DEV_73DF); the fixture therefore would not enter its WARP fallback but would test the iGPU. Could the rig honor XCL_ADAPTER, or at least print the actual device adapter and WARP fallback status, before these results are counted as RX 6800M coverage? This is source review plus an external default-device probe; I did not run the PR tests.
AI-assisted review: OpenAI Codex (GPT-6; exact serving variant unavailable) and a Luna subagent.
There was a problem hiding this comment.
Thanks @luckyteagirl for catching this, and @futurepro62 for the full-suite report. You are right: our two new tests share put_off_rig at list_x.rs:7124, whose D3D12CreateDevice(None, ...) call at 7129 ignores XCL_ADAPTER. Their helper calls are at 7166 and 7228. On a hybrid machine they use the default adapter, or WARP if default-device creation fails.
Checked: at 008201c4, list_x.rs has 15 direct D3D12CreateDevice(None, ...) call sites: this shared helper plus 14 other fixture calls at lines 4645, 4667, 4715, 5111, 5935, 6013, 6199, 6278, 6451, 6627, 6794, 6916, 7052 and 7267. Our tests followed that existing pattern, so their adapter attribution needs correcting.
@futurepro62, the two new tests in your “AMD iGPU (XCL_ADAPTER=radeon)” run therefore most likely ran on your default adapter. Could you confirm which adapter that is? We should hold their AMD-specific coverage attribution until the actual device is identified.
I can add the actual adapter name/LUID and WARP status to these two tests now. Making the broader list_x fixtures honor XCL_ADAPTER through gpu::adapter / the runner's selection pattern can be a separate test-only PR.
Not tested: no new device probe or GPU run for this reply; source inspection and the linked reports only.
AI use: Codex (GPT-6.1-Sol) checked the fixture call sites and drafted this reply. Claude Code (Claude Opus 5.5) checked the count and posted it.
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
AMD run of the two new tests, with the adapter shown. Head
So this is AMD coverage of the two tests, unlike the default-adapter runs discussed above. The fixture change will be its own test-only PR (the follow-up offered to @luckyteagirl). Not tested: RDNA3/4, Intel, a title run on AMD. AI use: Codex (GPT-6.1-Sol) wrote the temporary fixture change and ran the tests; Claude Code (Claude Opus 5.5) checked the log and wrote this comment. |
|
Independent synthetic Windows GPU verification on an AMD Radeon RX 7800 XT (RDNA3), driver Tested With
Both suites exited 101 on The same seven
Both full-suite logs identify the RX 7800 XT in the D3D12.X runtime. At the head, a temporary test-only probe matched each Close fixture device's LUID to the RX 7800 XT ( Repeating the same targeted command with the temporary Not tested Retail title smoke runs, release builds, and other adapters. AI use Claude Code (Claude Opus 5.5) ran the exact-head build and suite. Codex (gpt-6.2-sol) ran the exact-parent build and suite, ran the temporary adapter and causal checks, compared the saved logs, and wrote this test report. |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
…+ xcl-dev#2548 + xcl-dev#2579 + xcl-dev#2581 + xcl-dev#2598 + xcl-dev#2611 + xcl-dev#2615 + xcl-dev#2622) (cherry picked from commit 57e5c216e924452b59cd64862d2941006e24c28c)
|
Finding on #2622 head I extended the existing refused- Tested: RTX 3080 Ti (NVIDIA 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. Not tested: a retail title, paired clean-tree smoke, repeated failure under a live workload, or a refused middle call with later deferred calls. This is an author-ready local suggestion, not a merge-readiness claim. Local test and fix diff (not committed)diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs
index dddb6c4..c8fe256 100644
--- a/crates/xcl/src/hle/d3d12x/list_x.rs
+++ b/crates/xcl/src/hle/d3d12x/list_x.rs
@@ -3008,7 +3008,9 @@ unsafe fn deferred_segment(wrapper: *mut c_void, list: *mut c_void, ty: D3D12_CO
// a list that did not close is no segment: the call waits in its list instead
static CLOSE_ERR: AtomicU64 = AtomicU64::new(0);
warn(&CLOSE_ERR, "put-off segment", format_args!("Close failed ({hr:#x})"));
- super::title_list::put_spare(wrapper, p);
+ real::dispatch_chain::list_reset(p as usize);
+ let release = pc::<unsafe extern "system" fn(*mut c_void) -> u32>(p, 2);
+ release(p);
return None;
}
super::title_list::push_segment(wrapper, p);
@@ -7171,6 +7173,10 @@ mod tests {
let mut segs = Vec::new();
assert!(title_list::push_segments(wrap, &mut segs));
assert_eq!(segs.len(), 3, "the dispatch was put off");
+ let refused = segs[1];
+ let add_ref: unsafe extern "system" fn(*mut c_void) -> u32 =
+ std::mem::transmute(*(*(refused as *const *const usize)).add(1));
+ add_ref(refused); // Keep a test reference so final Release can reveal a lost owner.
// the replay's recording fails in the runtime: a query begun and never ended
let mut heap: Option<ID3D12QueryHeap> = None;
@@ -7203,8 +7209,14 @@ mod tests {
crate::gpu::fence::wait(&done, 1, &dev, None, 2000).expect("the submission runs");
assert!(dev.GetDeviceRemovedReason().is_ok(), "the device stays");
+ // The failed-Close list cannot Reset. Its next spare reuse must not lose the
+ // wrapper's owning reference when a new segment is made instead.
+ assert!(deferred_segment(wrap, pc0, D3D12_COMMAND_LIST_TYPE_DIRECT).is_some());
let rel_fn: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(*(*(wrap as *const *const usize)).add(2));
rel_fn(wrap);
+ let release_ref: unsafe extern "system" fn(*mut c_void) -> u32 =
+ std::mem::transmute(*(*(refused as *const *const usize)).add(2));
+ assert_eq!(release_ref(refused), 0, "the refused segment retained an untracked owner");
let _ = pso_async::released(standin);
}
}
diff --git a/crates/xcl/src/hle/d3d12x/title_list.rs b/crates/xcl/src/hle/d3d12x/title_list.rs
index 2aa8a6c..882139e 100644
--- a/crates/xcl/src/hle/d3d12x/title_list.rs
+++ b/crates/xcl/src/hle/d3d12x/title_list.rs
@@ -292,14 +292,17 @@ pub(super) fn put_spare(wrapper: *mut c_void, pc: *mut c_void) {
sg.get_or_insert_with(HashMap::new).entry(wrapper as usize).or_default().spares.push(pc as usize);
}
-/// Take segment `pc` out of `wrapper`'s recording, so it is not submitted (its recording failed);
-/// it stays with the spares, released with them.
-pub(super) fn drop_segment(wrapper: *mut c_void, pc: *mut c_void) {
+/// Take a refused segment out of `wrapper`'s recording and release it. A list whose Close failed
+/// cannot be reset, so it cannot be kept as a reusable spare.
+pub(super) unsafe fn drop_segment(wrapper: *mut c_void, pc: *mut c_void) {
let mut sg = SEGMENTS.lock().unwrap();
if let Some(b) = sg.as_mut().and_then(|m| m.get_mut(&(wrapper as usize))) {
b.extra_active.retain(|&p| p != pc as usize);
- b.spares.push(pc as usize);
}
+ drop(sg);
+ super::real::dispatch_chain::list_reset(pc as usize);
+ let release: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(pc_slot(pc, 2));
+ release(pc);
}
/// Add the closed segment `pc` to `wrapper`'s recording, after the ones it has.AI-assisted: Codex (GPT-6.2 Sol) traced the ownership path, wrote and ran the regression and local patch, and drafted this report. GPT-6.2 Astra reviewed the deferred segment and scratch lifetimes. |
|
Thanks @thehollowedone, that is a real leak, and thank you for the test that proves it and the patch. We will take your change: a refused segment is released instead of going to the spares, in both AI use: Claude Code (Claude Opus 5.5) wrote this. |
Apply thehollowedone's patch and reference-count regression from xcl-dev#2622 comment 7187891221. A list whose Close failed cannot be reset, so release it rather than losing its owner on later spare reuse, and clear its dispatch-chain predecessor. Adjust the suggested initial-refusal Release call to use the adopted vtable too: cl_release must clean address-keyed state instead of bypassing it through orig_fn. This is the same lifecycle class discussed in xcl-dev#1453 and xcl-dev#2691. Assisted-by: Codex (GPT-6.1-Sol)
|
@thehollowedone your fix is in One change from your diff: in AI use: Codex (GPT-6.1-Sol) applied the patch and ran the tests. Claude Code (Claude Opus 5.5) checked the diff and wrote this reply. |
Related: #2118 (the put-off-to-the-submit path), #2088. Found by @KOLESNiii in a static review (#2088 (comment)).
The path that puts a call off to a segment of its own, recorded at
ExecuteCommandLists(#2118), ignored the nativeCloseresult twice:deferred_segmentclosed the new empty segment and added it to the recording whateverClosereturned;record_deferredclosed the segment after recording the call, ignored the result, and made it the next segment's predecessor.A segment whose recording the runtime refused was then submitted with the rest. In a test, submitting one removed the device (
0x887A0001, an invalid call).What is in it
Review fix
f0f9daee(thehollowedone's finding, D3D12.X: a put-off call's segment that does not close is not submitted #2622 (comment)): a put-off segment whose nativeClosefails is released instead of being kept as a spare (a spare that cannot be reset lost its owning reference), in bothdeferred_segmentanddrop_segment, and its dispatch-chain predecessor entry is cleared. This is their patch and test, with one change: the first-refusal release goes through the adopted vtable likedrop_segment, socl_releasecleans the list's address-keyed state.crates/xcl/src/hle/d3d12x/list_x.rs:segment_close: the native Close of a put-off segment, with its HRESULT (and a test-only hook).deferred_segment: if the empty segment doesn't close, it isn't used; the list goes back to the spares and the call waits in its list, as it did before D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118.record_deferred: if the segment doesn't close after the call is recorded, it leaves the recording (title_list::drop_segment; it stays with the spares and is released with them). A list whose Close failed is still open and can't be Reset (E_FAIL, measured), so it can't be emptied. The call is dropped and counted (as a failed Reset there already is), the next segment doesn't follow it, and a warning is logged.crates/xcl/src/hle/d3d12x/title_list.rs:drop_segment.Tests:
a_put_off_call_whose_close_fails_is_not_submitted: the replay's recording is made to fail in the runtime (a query begun and never ended); the submission still runs and its fence is signalled, and the device stays.a_put_off_segment_that_does_not_close_is_not_used: nothing is put off when the empty segment doesn't close.Tested
Review fix
f0f9daee, RTX 5090,XCL_NETWORK=0: thehollowedone's reference-count test on the previous head: 0 passed, 1 failed (finalReleasereturned 1); with the fix:a_put_off_2 passed, 0 failed (finalRelease0).list_x42 passed, 0 failed, no SKIPPED.cargo build --workspacepassed. The smoke pair below ismainagainst this head (200 s, same recipe).RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.99.1, debug tests. Base
mainb49be18; head008201c.Both tests fail with
main's behaviour at the two sites (the segment code otherwise the same): "the refused segment is not submitted" (left: 3,right: 2) and "nothing was put off" (left: 3,right: 1). Both pass with the change: 20 of 20 runs with--test-threads=4.In the first test the runtime refuses the recording itself (a query begun and never ended, then the native
Close: the test asserts it fails). The test hook is#[cfg(test)]and keyed by the wrapper, so tests running in parallel don't take each other's hook.cargo test -p xcl --lib hle::d3d12x -- --test-threads=4: 256 passed, 0 failed, 2 ignored.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on008201c(
XCL_NETWORK=0): 1433 passed, 4 failed, 47 ignored over 37 test binaries. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState0x8007000E, seeds70 / 545 / 1019 / 1507). They fail the same way on
mainb49be18(pre-existing, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905).--no-fail-fastbecause otherwise those 4 stop cargo before the integration tests.SKIPPED (26 lines): GPU tests or forms that need wave64 (no wave64 on this card); 3 f16/f32 forms the
per-lane lowering refuses (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426);
heap_window_out_of_memory_falls_back_to_the_switch_form(no heapwindows);
pso_measurement_compiles_an_exact_synthetic_record(needs Developer Mode).Regression run
main:This PR (
008201c):Both: the retail title,
-Seconds 200,XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, the same scripted input to the world load, each on a copy of the same cache (compute precompiled, graphics driver blobs removed) under a never-used exe name. Both stop presenting at the world load (#2088).Tested by others (thank you):
008201c4: whole suite 1425 passed, 0 failed (main's known failures skipped); both new tests pass. On the Ryzen iGPU (RDNA2,XCL_ADAPTER=radeon): 1436 passed, 0 failed. Note: the new tests' fixture uses the default adapter (see the review thread), soXCL_ADAPTERdid not select it on every machine. D3D12.X: a put-off call's segment that does not close is not submitted #2622 (comment)main:cargo test -p xcl --liball passed, 0 failed. D3D12.X: a put-off call's segment that does not close is not submitted #2622 (comment)Not tested
f0f9daee(the earlier whole-suite results above are from008201c4).Closefailing on its own in a title run: not seen in ours (noClose failedline in either smoke run); the failure is injected in the tests.Edge cases we would like tested
Results on other hardware are very welcome here. Please give the commit, GPU, driver and the output.
Close, and what a refused list does when submitted, is up to the driver.cargo test -p xcl --lib a_put_off_ -- --test-threads=4Look for: both pass. In the first, the assertion that the runtime refused the recording (a query begun and never ended) passes, the submission runs, and the device stays. If
Closeisn't refused on your driver, that assertion fails and names the HRESULT: please post it.Closeat all. If it doesn't, the first test fails at "the runtime refused the recording", which says how a refused recording surfaces there.ExecuteCommandListscompletes.KickoffXpath.KickoffXchecks its own list'sClose, then calls the samerecord_deferred. A put-off call refused there should be dropped the same way. Look for: thedeferred call: Close failedwarning and no device removal.XCL_D3D12_DEBUG=1). Look for: whether any put-off segment is ever refused in practice, i.e. the log linesD3D12.X: deferred call: Close failed (…)orD3D12.X: put-off segment: Close failed (…), and the debug layer's message for that list. We saw none in our runs without the debug layer.Related but not changed here: @KOLESNiii's second case. A put-off call is taken out of its segment before a bounded resolve (
XCL_PSO_WAIT_MS) can skip it, so after a timed-out dispatch, a reusable list submitted again may still be missing that dispatch. This is a separate question from theCloseresults, and this PR doesn't touch it.AI use
🤖 Generated with Claude Code