Tracking: Verified crashes, memory-safety bugs, hangs, and GPU/shader blockers for playable Xbox builds #533

Open
opened 2026-12-05 08:27:51 +00:00 by gamer · 1 comment

Summary

Tracking issue for verified crashes, memory-safety bugs, hangs, rendering/shader defects, and build/stability blockers affecting playable Xbox builds on main.


Critical (Crashes, Memory Safety, Dropped Rendering)

  • Task-queue handle UAF (crates/darner-hle/src/modules/xasync.rs:655-664, 724-727, 1267)
    queue() calls Arc::increment_strong_count(handle) on raw *const Queue without validation. If the title closes/reuses the handle during complete_call, this causes a UAF and heap corruption. Fix: Use a handle table with generation counters or capture Arc clones on commit.
  • APU audio heap UAF race (crates/darner-hle/src/modules/audio.rs:167-177, 226-234)
    heap_bytes() drops the HEAP lock and returns &'a mut [u8] with an unbounded lifetime while heap_free() can dealloc the block from another thread. Fix: Track active in-flight decoder borrows or copy/pin blocks until decode completes.
  • Unchecked APU input slice (crates/darner-hle/src/modules/apu.rs:434)
    std::slice::from_raw_parts(input, input_length as usize) only checks input.is_null(), not input_length bounds or backing memory. Fix: Validate length/bounds against mapped audio heap ranges.
  • XMemFreeDefault arbitrary header read (crates/darner-hle/src/modules/xmem.rs:1096-1117)
    Reads user.sub(HEADER).cast::<AllocHeader>().read() and calls dealloc/VirtualFree with no magic/generation check; double-frees or external pointers corrupt the host heap. Fix: Validate a magic tag and generation before freeing.
  • Non-crash-safe crash reporter & VEH deadlock (crates/darner-loader/src/crash.rs:700-764; crates/darner-loader/src/console_insn.rs:395)
    report() allocates (String::new(), format!, Vec, eprintln!) inside the exception filter, and PATCHING: Mutex is held across VirtualProtect/allocation—causing deadlocks or lost crash logs on heap-lock AVs or nested faults. Fix: Use a pre-allocated static buffer + raw WriteFile in crash.rs, and a reentrancy guard in the VEH.
  • CancelRequestsWithTag is a no-op (crates/darner-hle/src/modules/dstorage.rs:2321-2327)
    Logs a warning and lets queued reads complete, risking writes into freed/reused title buffers. Fix: Cancel unstarted matching requests with E_ABORT.
  • Write-watch trampoline rsp-relative corruption & unchecked reads (crates/darner-loader/src/write_sites.rs:97, 145, 253, 276)
    vector_stub (lea rsp, [rsp-32]) and move_stub (push rcx) shift rsp before executing [m]; apply() reads 16 bytes with ptr::read_unaligned without VirtualQuery or checked_add, and skips FlushInstructionCache on the new stub to.
  • Stale VirtualQuery cache & multi-thread clzero patching race (crates/darner-loader/src/console_insn.rs:44, 297, 323, 554)
    Thread-local WRITABLE cache is never invalidated on VirtualFree/VirtualProtect; zero_through_fault writes to MEM_RESERVE pages; patch_clzero overwrites 5 bytes in place by default, risking 0xc000001d on concurrent threads.
  • Infinite GPU fence wait in VEH readback (crates/darner-gpu/src/gpu_owned.rs:435, 518, 538-578)
    read_back holds ENGINE.lock() and calls WaitForSingleObject(..., INFINITE), freezing all faulting threads on GPU hang/TDR.
  • First-touch shader reads/writes to non-buffer memory dropped (crates/darner-gpu/src/memory.rs:29-31; crates/darner-gpu/src/dxr.rs)
    Unmapped 64 KiB pages return 0 and drop stores on first access, breaking BVH/RT dispatches (DARNER_BVH_BUILDER=1).
  • 0x1c8 graphics pipeline deserialization returns E_NOTIMPL (crates/darner-gpu/src/device.rs:959, 743-756; crates/darner-shader/src/native.rs:527; docs/loose-pipelines.md:6-9)
    f[57] routes to unknown_pipeline::<0x1c8> (reads only 128 bytes instead of ~264) and returns E_NOTIMPL, contributing to 3–29% dropped draws. Requires a console-register-packet GraphicsState decoder (never return S_OK without a built HostPipeline).
  • Approximate Wave64 lowering silently emits corrupt shaders (crates/darner-shader/src/emit/mod.rs:999-1005; crates/darner-shader/src/emit/lower.rs:10613-10620)
    with_local_waves_any masks lanes with & 31, silently splitting 64-lane v_readlane across two 32-lane waves.
  • Wave32 census command skips set_host_max_wave (apps/darner/src/main.rs:788-790 vs docs/findings.md:259-262)
    Command::Shaders never sets host max wave size, so darner shaders reports zero Wave64 failures.

High (Hangs, Panics, Compatibility)

  • Byte-pattern TLS patching instead of instruction decoding (crates/darner-loader/src/tls.rs:86-99)
    Matches mov r64, gs:[0x58] by raw bytes; false positives inside instructions on other titles/builds will crash on first TLS access.
  • PE loader trusts size_of_image, first-matching section, and truncates export VAs (crates/darner-pe/src/image.rs:233-245, 337-343, 373)
  • Blocking fence waits have no default watchdog timeout (crates/darner-gpu/src/fence.rs:213-254; crates/darner-gpu/src/host.rs:8343-8376)
    DARNER_FENCE_WAIT_MS is opt-in; stuck fences loop indefinitely with 5s warnings. Fix: Add a default watchdog that dumps device state and exits cleanly.
  • Device removal & ResizeBuffers retry loop cause dead/black frames (crates/darner-gpu/src/draw.rs:5311-5319; crates/darner-gpu/src/host.rs:20185-20218)
  • Title-thread .unwrap() panics in facewatch::wrote() (crates/darner-gpu/src/facewatch.rs:235, 254, 273, 293, 350)
  • Shader parser/spill/bitcode gaps (crates/darner-shader/src/native.rs:64-69; spill.rs:25, 39-55, 67-70; emit/bitcode.rs:355)
    Merged stages and 0x0e tables unread; spill.rs only handles compute SGPR-16 constant-dword spills; bitcode::aggregate panics on non-constants.
  • Host export forwarding panics on missing DLL exports (crates/darner-hle/src/modules/files.rs:32)
    host! macro panics instead of returning a Win32 error / E_NOTIMPL.
  • Incomplete DirectStorage & Store HLE stubs (crates/darner-hle/src/modules/dstorage.rs:1-5; crates/darner-hle/src/modules/xstore.rs)
    Newer GDK DirectStorage slots only log; xstore reports zero DLCs and fails catalog/update queries.
  • Restart mutex 60s timeout allows dual-instance save/cache corruption (apps/darner/src/play.rs:826-857; crates/darner-gpu/src/host/menu.rs:3098-3140)
    one_at_a_time_in proceeds after 60s even if the previous instance hasn't exited.

Medium (Leaks, Overflows, Stability)

  • Streaming retirement disabled by default & drops oldest ranges (crates/darner-gpu/src/stream_retire.rs:4-5, 66-72, 117, 210-212; resource.rs:4706)
    Disabled state triggers ~8,192 VirtualQuery/s; enabled state drops pop_front() at MAX_QUEUE_LEN = 16_384.
  • Timeline recorder 20 ms sleep + assume_init() race (crates/darner-gpu/src/timeline/record.rs:666-688)
  • Unbounded BDD recursion stack-overflow risk (crates/darner-shader/src/structure.rs:356, 383-384)
  • Unchecked tx * ty * tz compute group multiplication (crates/darner-shader/src/fold.rs:1467; crates/darner-shader/src/native.rs:855-859)
  • Unclamped quant_step accumulator in XMA decoder (crates/darner-formats/src/xma.rs:1224-1237)
  • DARNER_DUE_INDEX release panics & unpruned held walk (crates/darner-gpu/src/descriptor/host.rs:1818-1836)
  • Unbounded guest pointer reads in compute deserialize (crates/darner-gpu/src/pipeline.rs:1072-1074; device.rs:824-830)
  • Intentional D3D12 buffer leak on swapchain resize/scale (crates/darner-gpu/src/host/panel.rs:1411, 1512, 1520)
  • Ignored VirtualProtect restore failures & PreparedImage::patch overwrite (crates/darner-loader/src/tls.rs:67, cbv_align.rs:113, windows.rs:268, 455, prepare.rs)
  • Corruptible DARNER_SLOTS_BITMAP=1 lacks startup warning (crates/darner-gpu/src/descriptor/slots.rs:35-43)
  • Frame-gen 20% VRAM holdback & hardcoded Streamline SDK fallback (crates/darner-gpu/src/streamline.rs:18-19, 57)

## Summary Tracking issue for verified crashes, memory-safety bugs, hangs, rendering/shader defects, and build/stability blockers affecting playable Xbox builds on `main`. --- ## Critical (Crashes, Memory Safety, Dropped Rendering) - [ ] **Task-queue handle UAF** (`crates/darner-hle/src/modules/xasync.rs:655-664, 724-727, 1267`) `queue()` calls `Arc::increment_strong_count(handle)` on raw `*const Queue` without validation. If the title closes/reuses the handle during `complete_call`, this causes a UAF and heap corruption. **Fix:** Use a handle table with generation counters or capture `Arc` clones on commit. - [ ] **APU audio heap UAF race** (`crates/darner-hle/src/modules/audio.rs:167-177, 226-234`) `heap_bytes()` drops the `HEAP` lock and returns `&'a mut [u8]` with an unbounded lifetime while `heap_free()` can `dealloc` the block from another thread. **Fix:** Track active in-flight decoder borrows or copy/pin blocks until decode completes. - [ ] **Unchecked APU input slice** (`crates/darner-hle/src/modules/apu.rs:434`) `std::slice::from_raw_parts(input, input_length as usize)` only checks `input.is_null()`, not `input_length` bounds or backing memory. **Fix:** Validate length/bounds against mapped audio heap ranges. - [ ] **`XMemFreeDefault` arbitrary header read** (`crates/darner-hle/src/modules/xmem.rs:1096-1117`) Reads `user.sub(HEADER).cast::<AllocHeader>().read()` and calls `dealloc`/`VirtualFree` with no magic/generation check; double-frees or external pointers corrupt the host heap. **Fix:** Validate a magic tag and generation before freeing. - [ ] **Non-crash-safe crash reporter & VEH deadlock** (`crates/darner-loader/src/crash.rs:700-764`; `crates/darner-loader/src/console_insn.rs:395`) `report()` allocates (`String::new()`, `format!`, `Vec`, `eprintln!`) inside the exception filter, and `PATCHING: Mutex` is held across `VirtualProtect`/allocation—causing deadlocks or lost crash logs on heap-lock AVs or nested faults. **Fix:** Use a pre-allocated static buffer + raw `WriteFile` in `crash.rs`, and a reentrancy guard in the VEH. - [ ] **`CancelRequestsWithTag` is a no-op** (`crates/darner-hle/src/modules/dstorage.rs:2321-2327`) Logs a warning and lets queued reads complete, risking writes into freed/reused title buffers. **Fix:** Cancel unstarted matching requests with `E_ABORT`. - [ ] **Write-watch trampoline `rsp`-relative corruption & unchecked reads** (`crates/darner-loader/src/write_sites.rs:97, 145, 253, 276`) `vector_stub` (`lea rsp, [rsp-32]`) and `move_stub` (`push rcx`) shift `rsp` before executing `[m]`; `apply()` reads 16 bytes with `ptr::read_unaligned` without `VirtualQuery` or `checked_add`, and skips `FlushInstructionCache` on the new stub `to`. - [ ] **Stale `VirtualQuery` cache & multi-thread `clzero` patching race** (`crates/darner-loader/src/console_insn.rs:44, 297, 323, 554`) Thread-local `WRITABLE` cache is never invalidated on `VirtualFree`/`VirtualProtect`; `zero_through_fault` writes to `MEM_RESERVE` pages; `patch_clzero` overwrites 5 bytes in place by default, risking `0xc000001d` on concurrent threads. - [ ] **Infinite GPU fence wait in VEH readback** (`crates/darner-gpu/src/gpu_owned.rs:435, 518, 538-578`) `read_back` holds `ENGINE.lock()` and calls `WaitForSingleObject(..., INFINITE)`, freezing all faulting threads on GPU hang/TDR. - [ ] **First-touch shader reads/writes to non-buffer memory dropped** (`crates/darner-gpu/src/memory.rs:29-31`; `crates/darner-gpu/src/dxr.rs`) Unmapped 64 KiB pages return `0` and drop stores on first access, breaking BVH/RT dispatches (`DARNER_BVH_BUILDER=1`). - [ ] **`0x1c8` graphics pipeline deserialization returns `E_NOTIMPL`** (`crates/darner-gpu/src/device.rs:959, 743-756`; `crates/darner-shader/src/native.rs:527`; `docs/loose-pipelines.md:6-9`) `f[57]` routes to `unknown_pipeline::<0x1c8>` (reads only 128 bytes instead of ~264) and returns `E_NOTIMPL`, contributing to 3–29% dropped draws. Requires a console-register-packet `GraphicsState` decoder (never return `S_OK` without a built `HostPipeline`). - [ ] **Approximate Wave64 lowering silently emits corrupt shaders** (`crates/darner-shader/src/emit/mod.rs:999-1005`; `crates/darner-shader/src/emit/lower.rs:10613-10620`) `with_local_waves_any` masks lanes with `& 31`, silently splitting 64-lane `v_readlane` across two 32-lane waves. - [ ] **Wave32 census command skips `set_host_max_wave`** (`apps/darner/src/main.rs:788-790` vs `docs/findings.md:259-262`) `Command::Shaders` never sets host max wave size, so `darner shaders` reports zero Wave64 failures. --- ## High (Hangs, Panics, Compatibility) - [ ] **Byte-pattern TLS patching instead of instruction decoding** (`crates/darner-loader/src/tls.rs:86-99`) Matches `mov r64, gs:[0x58]` by raw bytes; false positives inside instructions on other titles/builds will crash on first TLS access. - [ ] **PE loader trusts `size_of_image`, first-matching section, and truncates export VAs** (`crates/darner-pe/src/image.rs:233-245, 337-343, 373`) - [ ] **Blocking fence waits have no default watchdog timeout** (`crates/darner-gpu/src/fence.rs:213-254`; `crates/darner-gpu/src/host.rs:8343-8376`) `DARNER_FENCE_WAIT_MS` is opt-in; stuck fences loop indefinitely with 5s warnings. **Fix:** Add a default watchdog that dumps device state and exits cleanly. - [ ] **Device removal & `ResizeBuffers` retry loop cause dead/black frames** (`crates/darner-gpu/src/draw.rs:5311-5319`; `crates/darner-gpu/src/host.rs:20185-20218`) - [ ] **Title-thread `.unwrap()` panics in `facewatch::wrote()`** (`crates/darner-gpu/src/facewatch.rs:235, 254, 273, 293, 350`) - [ ] **Shader parser/spill/bitcode gaps** (`crates/darner-shader/src/native.rs:64-69`; `spill.rs:25, 39-55, 67-70`; `emit/bitcode.rs:355`) Merged stages and `0x0e` tables unread; `spill.rs` only handles compute SGPR-16 constant-dword spills; `bitcode::aggregate` panics on non-constants. - [ ] **Host export forwarding panics on missing DLL exports** (`crates/darner-hle/src/modules/files.rs:32`) `host!` macro panics instead of returning a Win32 error / `E_NOTIMPL`. - [ ] **Incomplete DirectStorage & Store HLE stubs** (`crates/darner-hle/src/modules/dstorage.rs:1-5`; `crates/darner-hle/src/modules/xstore.rs`) Newer GDK DirectStorage slots only log; `xstore` reports zero DLCs and fails catalog/update queries. - [ ] **Restart mutex 60s timeout allows dual-instance save/cache corruption** (`apps/darner/src/play.rs:826-857`; `crates/darner-gpu/src/host/menu.rs:3098-3140`) `one_at_a_time_in` proceeds after 60s even if the previous instance hasn't exited. --- ## Medium (Leaks, Overflows, Stability) - [ ] **Streaming retirement disabled by default & drops oldest ranges** (`crates/darner-gpu/src/stream_retire.rs:4-5, 66-72, 117, 210-212`; `resource.rs:4706`) Disabled state triggers ~8,192 `VirtualQuery`/s; enabled state drops `pop_front()` at `MAX_QUEUE_LEN = 16_384`. - [ ] **Timeline recorder 20 ms sleep + `assume_init()` race** (`crates/darner-gpu/src/timeline/record.rs:666-688`) - [ ] **Unbounded BDD recursion stack-overflow risk** (`crates/darner-shader/src/structure.rs:356, 383-384`) - [ ] **Unchecked `tx * ty * tz` compute group multiplication** (`crates/darner-shader/src/fold.rs:1467`; `crates/darner-shader/src/native.rs:855-859`) - [ ] **Unclamped `quant_step` accumulator in XMA decoder** (`crates/darner-formats/src/xma.rs:1224-1237`) - [ ] **`DARNER_DUE_INDEX` release panics & unpruned `held` walk** (`crates/darner-gpu/src/descriptor/host.rs:1818-1836`) - [ ] **Unbounded guest pointer reads in compute deserialize** (`crates/darner-gpu/src/pipeline.rs:1072-1074`; `device.rs:824-830`) - [ ] **Intentional D3D12 buffer leak on swapchain resize/scale** (`crates/darner-gpu/src/host/panel.rs:1411, 1512, 1520`) - [ ] **Ignored `VirtualProtect` restore failures & `PreparedImage::patch` overwrite** (`crates/darner-loader/src/tls.rs:67`, `cbv_align.rs:113`, `windows.rs:268, 455`, `prepare.rs`) - [ ] **Corruptible `DARNER_SLOTS_BITMAP=1` lacks startup warning** (`crates/darner-gpu/src/descriptor/slots.rs:35-43`) - [ ] **Frame-gen 20% VRAM holdback & hardcoded Streamline SDK fallback** (`crates/darner-gpu/src/streamline.rs:18-19, 57`) ---

Static audit of the 33 items (source reading, no build)

I read the cited files on main (2026-12-05). This is a code-level check only: it confirms the cited pattern, not runtime reproduction.

Result: 26 confirmed by code, 6 partial, 1 not confirmed.

Partial:

  • #5 crash reporter/VEH: allocation in the filter is visible; the PATCHING lock across VirtualProtect is not fully traced.
  • #7 write-watch trampoline: unchecked 16-byte read and ignored restore are visible; the rsp shifts were not in the cited stub portions.
  • #15 PE loader: bounds checks exist; first-section lookup and wrapping_sub(image_base) as u32 remain.
  • #17 ResizeBuffers: the retry exists (SwapChainRetry, once per second); dead/black frames are not proven by code, and the cited draw.rs:5311-5319 is texture-upload admission.
  • #23 stream retire: off by default and drop-oldest at 16,384 confirmed; the ~8,192 VirtualQuery/s figure is not in stream_retire.rs.
  • #24 timeline: 20 ms sleep and assume_init() confirmed; the race is plausible, not proven.

Not confirmed: #33 (frame-gen 20% VRAM holdback). streamline.rs:18-19 is DARNER_THIN/DARNER_ASYNC_SUBMIT; :57 is DEFAULT_DIR. No holdback/reserve/20% in streamline.rs, streamline/plan.rs, streamline/fsr.rs, or streamline/fg_rect.rs.

Most useful confirmations:

  • #12: lower.rs:10830-10835 masks the lane with & 31 in the approximate local-wave path. Exact64 is the safe path.
  • #13: main.rs:800-801 (Command::Shaders -> precompile) never calls set_host_max_wave; only translate::run does (translate.rs:288-289), and from DARNER_HOST_MAX_WAVE, not DARNER_HOST_WAVE.
  • #11: device.rs:959/1053 returns E_NOTIMPL for 0x1c8; docs/loose-pipelines.md says 3-29% dropped draws.
  • #9/#16: gpu_owned.rs:435/518 use INFINITE; fence.rs has no default watchdog.
  • #22: play.rs:977-980 waits 60 s and then starts anyway.

"Confirmed" means the cited code matches the claim. It does not prove the bug reproduces; several items need ASan, a debugger, or a crafted input.

## Static audit of the 33 items (source reading, no build) I read the cited files on `main` (2026-12-05). This is a code-level check only: it confirms the cited pattern, not runtime reproduction. **Result: 26 confirmed by code, 6 partial, 1 not confirmed.** Partial: - **#5** crash reporter/VEH: allocation in the filter is visible; the `PATCHING` lock across `VirtualProtect` is not fully traced. - **#7** write-watch trampoline: unchecked 16-byte read and ignored restore are visible; the `rsp` shifts were not in the cited stub portions. - **#15** PE loader: bounds checks exist; first-section lookup and `wrapping_sub(image_base) as u32` remain. - **#17** ResizeBuffers: the retry exists (`SwapChainRetry`, once per second); dead/black frames are not proven by code, and the cited `draw.rs:5311-5319` is texture-upload admission. - **#23** stream retire: off by default and drop-oldest at 16,384 confirmed; the ~8,192 `VirtualQuery`/s figure is not in `stream_retire.rs`. - **#24** timeline: 20 ms sleep and `assume_init()` confirmed; the race is plausible, not proven. **Not confirmed: #33 (frame-gen 20% VRAM holdback).** `streamline.rs:18-19` is `DARNER_THIN`/`DARNER_ASYNC_SUBMIT`; `:57` is `DEFAULT_DIR`. No `holdback`/`reserve`/`20%` in `streamline.rs`, `streamline/plan.rs`, `streamline/fsr.rs`, or `streamline/fg_rect.rs`. Most useful confirmations: - **#12**: `lower.rs:10830-10835` masks the lane with `& 31` in the approximate local-wave path. Exact64 is the safe path. - **#13**: `main.rs:800-801` (`Command::Shaders` -> `precompile`) never calls `set_host_max_wave`; only `translate::run` does (`translate.rs:288-289`), and from `DARNER_HOST_MAX_WAVE`, not `DARNER_HOST_WAVE`. - **#11**: `device.rs:959/1053` returns `E_NOTIMPL` for `0x1c8`; `docs/loose-pipelines.md` says 3-29% dropped draws. - **#9/#16**: `gpu_owned.rs:435/518` use `INFINITE`; `fence.rs` has no default watchdog. - **#22**: `play.rs:977-980` waits 60 s and then starts anyway. "Confirmed" means the cited code matches the claim. It does not prove the bug reproduces; several items need ASan, a debugger, or a crafted input.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner#533
No description provided.