D3D12.X: XCL_DRED=1 leaks memory unboundedly and reports Frame 1 pipeline labels because list_x::reset_pc and kickoff_x bypass real::cl_reset #2452

Open
opened 2026-11-25 19:30:22 +00:00 by microwave805 · 1 comment
microwave805 commented 2026-11-25 19:30:22 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-25T19:30:22Z.


Static audit on main @ c7e1799 found that XCL_DRED=1 (#1592) leaks memory unboundedly and reports stale Frame 1 pipeline labels on every wrapped console command list because list_x::reset_pc and list_x::kickoff_x bypass real::cl_reset.

Where

  • crates/xcl/src/hle/d3d12x/list_x.rs:3883-3933 (reset_pc)
  • crates/xcl/src/hle/d3d12x/list_x.rs:3228-3242 (kickoff_x)
  • crates/xcl/src/hle/d3d12x/title_list.rs:154-202, 214-216 (reset, reset_139)
  • crates/xcl/src/hle/d3d12x/real.rs:2981-2996 (cl_reset)
  • crates/xcl/src/hle/d3d12x/dred.rs:92-101, 123-156 (reset, recording_of, bound_after, bound_at)

Root cause

dred::reset and dred::mark_pipeline (for initial_state) are wired into real::cl_reset (real.rs:2990-2993) and list_x::try_split_for_wait (list_x.rs:2701-2704), but every wrapped console command list routes both slot #10 Reset (title_list.rs:165) and newer-layout slot #139 Reset (title_list.rs:215) through title_list::reset → list_x::reset_pc (and reset_stand_in → list_x::reset_pc), which invokes native pc(this, PC_RESET) directly (list_x.rs:3891), bypassing real::cl_reset. list_x::kickoff_x (list_x.rs:3231) likewise calls pc(target, PC_RESET) directly.

Neither list_x::reset_pc nor list_x::kickoff_x calls super::dred::reset or super::dred::mark_pipeline.

Impact

With XCL_DRED=1 on any console title:

  1. Subsequent frame resets never start a new recording in dred::MARKS[pc]; every SetPipelineState / SetMarker across all frames appends forever into MARKS[pc][0] (RECORDINGS = 4 eviction at dred.rs:97 never runs → unbounded heap growth).
  2. On any GPU fault after a command list's first reset, recording_of() (dred.rs:123-126) fails r.len() == total (M markers in DRED vs N >> M accumulated in MARKS[pc][0]), falls back to MARKS[pc][0], and bound_at/bound_after index into Frame 1's markers (and miss initial_pso set via Reset / KickoffX).

Fix

  • After if hr < 0 in list_x::reset_pc (list_x.rs:3897):
    super::dred::reset(this);
    if pso != 0 {
        super::dred::mark_pipeline(this, pso, resolved);
    }
    
  • After if reset_hr < 0 in list_x::kickoff_x (list_x.rs:3237):
    super::dred::reset(target);
    if bound_pso != 0 {
        super::dred::mark_pipeline(target, bound_pso, init_pso);
    }
    

AI use

  • Antigravity (Gemini 4 Neon): static code audit on main @ c7e1799 and issue drafting.
<!-- greyfinch-sync:ivall/xcl:issue:6612107969 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2462). Originally posted by [microwave805](https://github.com/microwave805) on 2026-11-25T19:30:22Z. --- Static audit on `main @ c7e1799` found that `XCL_DRED=1` (#1592) leaks memory unboundedly and reports stale Frame 1 pipeline labels on every wrapped console command list because `list_x::reset_pc` and `list_x::kickoff_x` bypass `real::cl_reset`. ### Where - `crates/xcl/src/hle/d3d12x/list_x.rs:3883-3933` (`reset_pc`) - `crates/xcl/src/hle/d3d12x/list_x.rs:3228-3242` (`kickoff_x`) - `crates/xcl/src/hle/d3d12x/title_list.rs:154-202, 214-216` (`reset`, `reset_139`) - `crates/xcl/src/hle/d3d12x/real.rs:2981-2996` (`cl_reset`) - `crates/xcl/src/hle/d3d12x/dred.rs:92-101, 123-156` (`reset`, `recording_of`, `bound_after`, `bound_at`) ### Root cause `dred::reset` and `dred::mark_pipeline` (for `initial_state`) are wired into `real::cl_reset` (`real.rs:2990-2993`) and `list_x::try_split_for_wait` (`list_x.rs:2701-2704`), but **every wrapped console command list** routes both slot #10 `Reset` (`title_list.rs:165`) and newer-layout slot #139 `Reset` (`title_list.rs:215`) through `title_list::reset` → `list_x::reset_pc` (and `reset_stand_in` → `list_x::reset_pc`), which invokes native `pc(this, PC_RESET)` directly (`list_x.rs:3891`), bypassing `real::cl_reset`. `list_x::kickoff_x` (`list_x.rs:3231`) likewise calls `pc(target, PC_RESET)` directly. Neither `list_x::reset_pc` nor `list_x::kickoff_x` calls `super::dred::reset` or `super::dred::mark_pipeline`. ### Impact With `XCL_DRED=1` on any console title: 1. Subsequent frame resets never start a new recording in `dred::MARKS[pc]`; every `SetPipelineState` / `SetMarker` across all frames appends forever into `MARKS[pc][0]` (`RECORDINGS = 4` eviction at `dred.rs:97` never runs → unbounded heap growth). 2. On any GPU fault after a command list's first reset, `recording_of()` (`dred.rs:123-126`) fails `r.len() == total` (`M` markers in DRED vs `N >> M` accumulated in `MARKS[pc][0]`), falls back to `MARKS[pc][0]`, and `bound_at`/`bound_after` index into Frame 1's markers (and miss `initial_pso` set via `Reset` / `KickoffX`). ### Fix - After `if hr < 0` in `list_x::reset_pc` (`list_x.rs:3897`): ```rust super::dred::reset(this); if pso != 0 { super::dred::mark_pipeline(this, pso, resolved); } ``` - After `if reset_hr < 0` in `list_x::kickoff_x` (`list_x.rs:3237`): ```rust super::dred::reset(target); if bound_pso != 0 { super::dred::mark_pipeline(target, bound_pso, init_pso); } ``` ### AI use - Antigravity (Gemini 4 Neon): static code audit on `main @ c7e1799` and issue drafting.
oni-swr commented 2026-11-25 21:05:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T20:49:10Z.


Claiming this issue: wiring dred::reset and dred::mark_pipeline through list_x::reset_pc and list_x::kickoff_x so XCL_DRED=1 does not leak or report stale Frame 1 labels, with regression tests.
AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7174230287 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2462#issuecomment-7174230287). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T20:49:10Z. --- Claiming this issue: wiring dred::reset and dred::mark_pipeline through list_x::reset_pc and list_x::kickoff_x so XCL_DRED=1 does not leak or report stale Frame 1 labels, with regression tests. AI use: Claude Code (Claude Opus 5.5).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#2452
No description provided.