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 #2462

Open
opened 2026-11-26 05:31:21 +00:00 by github-bot · 1 comment
Owner

@⁠microwave805 on GitHub · 2026-11-25 19:30 UTC · original

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.
**@⁠microwave805** on GitHub · 2026-11-25 19:30 UTC · [original](https://github.com/xcl-dev/xcl/issues/2462) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:21 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 20:49 UTC · original

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).

**@⁠oni-swr** on GitHub · 2026-11-25 20:49 UTC · [original](https://github.com/xcl-dev/xcl/issues/2462#issuecomment-7174230287) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.