Tracking: Dynamic GetProcAddress, skipped Wave64 SSR/probes, GPU-owned/HLE races, pipeline lock contention, and test-coverage gaps #541

Open
opened 2026-12-05 09:49:04 +00:00 by gamer · 2 comments

Summary

Third tracking issue covering verified HLE/GPU concurrency races, skipped Wave64 screen-probe shaders, pipeline-creation lock contention, unchecked stream input parsing, and missing CPU/regression tests not listed in Issue #1 or Issue #2.


Critical (Memory Safety, Silent Visual Drops, Crashes)

  • Skipped Wave64 SSR / temporal-resolve / screen-probe shaders (crates/darner-shader/src/emit/lower/analysis.rs:329-341; emit/mod.rs:1160-1162; pipeline.rs:214)
    WIDE_SKIP_DEFAULT (20 hashes) drops reflection, temporal-resolve, and screen-probe programs when no exact barrier-free form takes them, leaving the ambient stand-in to light the scene. Fix: A/B DARNER_EXACT64 in gameplay and promote it to default for these programs (do not use the wave-wide form, which corrupts glossy surfaces).
  • Unchecked pipeline-stream D3D12_INPUT_LAYOUT_DESC parsing (crates/darner-gpu/src/pipeline/host.rs:236-248)
    NumElements, pInputElementDescs, and SemanticName from the title stream are passed unchecked to slice::from_raw_parts and CStr::from_ptr, risking title-thread crashes on malformed/truncated streams. Fix: Clamp NumElements, null-check pointers, copy via fault-tolerant readers, and add a non-null stream test.
  • GPU-owned fault readback lifetime race (DARNER_GPU_OWNED=1 / DARNER_LAZY_BACK=1) (crates/darner-gpu/src/gpu_owned.rs:583-605, 858-871)
    drop_range and the failed-arming rollback clear bits/map entries without setting gone or taking block_lock, allowing a concurrent faulting thread to copy stale staging bytes into freed title memory and double-decrement ACTIVE_COUNT. Fix: Set gone before clearing bits, re-check under block_lock, and decrement only on successful swap.

High (Compatibility, Hangs, Frame-Time Hitches)

  • GetProcAddress diverges from static import resolution (crates/darner-hle/src/modules/kernel.rs:240-271; registry.rs:59-66)
    GetProcAddress checks only the first module serving a DLL, never falls through to the host, and refuses ordinals—returning NULL for APIs that bind statically. Fix: Route pseudo-handles through registry::lookup + host policy, translate ordinal n to "#n", and test parity with static binding.
  • Wave64 census env mismatch & silent fallback when host wave is 0 (apps/darner/src/translate.rs:283-287, 567-570; emit/lower.rs:1130-1136; host.rs:2484-2490)
    translate reads DARNER_HOST_MAX_WAVE (not DARNER_HOST_WAVE), precompile sets neither, and failed CheckFeatureSupport leaves host wave at 0—silently disabling Wave64 lowering and dropping shadows/water/particles. Fix: Alias/unify the env var, set it in precompile, and default unknown host wave to 32 with a warning.
  • SHADERS mutex held across shader analysis & repeated container rescans (crates/darner-gpu/src/pipeline.rs:115-139; pipeline/make.rs:276-313, 348-360)
    SHADERS.lock() is held during ambient::role / mirror::part analysis, and containers are re-scanned/re-decoded per pipeline creation, serializing title threads and hitching on new content. Fix: Look up under lock, analyze outside the lock, and memoize per-Shader classifications in OnceLock.
  • HLE thread-lifetime crash & hang hazards
    • crates/darner-hle/src/mousehook.rs:247-250: Stack/hook imbalance calls std::process::abort(); log once and return instead.
    • crates/darner-hle/src/modules/xasync.rs:349-388: A panic in Timer::run's job() leaves state.1 = true forever, halting all delayed async completions; guard with catch_unwind or a Drop reset guard.
    • crates/darner-hle/src/runtime.rs:25-32, 117-132: image_size re-reads the PE header for every recorded image, risking a UAF if an entry outlives its mapping; cache size_of_image in ImagePath on registration.
    • crates/darner-hle/src/modules/kernel.rs:122-127: GetModuleFileNameA copies UTF-8 instead of the Windows ANSI code page; use host::ansi.

Medium (Bookkeeping, Power-Loss Safety, Worker Resilience)

  • take_out leaves stale held marks in descriptor queue (crates/darner-gpu/src/descriptor/host.rs:2107-2132, 2560-2564)
    take_out clears checked/mapped but not held, keeping has_held elevated until a later room() pass.
  • Pipeline cache publish skips sync_all() before rename (crates/darner-pipeline/src/cache.rs:144-154)
    Power loss before flush can leave a partial file as a permanent bogus cache hit; call sync_all() before rename and evict entries that fail validation.
  • Submission-path .expect() & silent texture-sweep thread death (crates/darner-gpu/src/host.rs:1039-1058, 3497; capture.rs:416-442)
    host.rs:3497 panics on prelude thread spawn failure (degrade to synchronous preludes); host.rs:1045 stops idle texture reclaim forever if let_go_idle() panics (wrap in catch_unwind); capture.rs uses an unbounded channel and can spin on device removal.

Low (Offline Test Coverage & Stale Docs)

  • Folded-Wave64 & s_getpc/far-jump tests require an SM 6.6 GPU or private bench paths (crates/darner-shader/src/emit/folded_tests.rs:181-248; oracle64.rs:1876; fold.rs:1214-1225, 1650-1691)
    Add default CPU tests using synthetic folded/far-branch programs verified against oracle64::check_fold.
  • Stale-texture-upload race test is #[ignore]d (crates/darner-gpu/src/texture/ahead.rs:715-716)
    Re-spawn the test binary with --exact and DARNER_PRELUDE_UPLOADS=1 (matching sampled.rs) so late_completion_keeps_a_newer_list_refresh runs by default.
  • Remove dead DARNER_ORACLE_* switches from docs/shader-memory-validation.md:62
## Summary Third tracking issue covering verified HLE/GPU concurrency races, skipped Wave64 screen-probe shaders, pipeline-creation lock contention, unchecked stream input parsing, and missing CPU/regression tests not listed in Issue #1 or Issue #2. --- ## Critical (Memory Safety, Silent Visual Drops, Crashes) - [ ] **Skipped Wave64 SSR / temporal-resolve / screen-probe shaders** (`crates/darner-shader/src/emit/lower/analysis.rs:329-341`; `emit/mod.rs:1160-1162`; `pipeline.rs:214`) `WIDE_SKIP_DEFAULT` (20 hashes) drops reflection, temporal-resolve, and screen-probe programs when no exact barrier-free form takes them, leaving the ambient stand-in to light the scene. **Fix:** A/B `DARNER_EXACT64` in gameplay and promote it to default for these programs (do not use the wave-wide form, which corrupts glossy surfaces). - [ ] **Unchecked pipeline-stream `D3D12_INPUT_LAYOUT_DESC` parsing** (`crates/darner-gpu/src/pipeline/host.rs:236-248`) `NumElements`, `pInputElementDescs`, and `SemanticName` from the title stream are passed unchecked to `slice::from_raw_parts` and `CStr::from_ptr`, risking title-thread crashes on malformed/truncated streams. **Fix:** Clamp `NumElements`, null-check pointers, copy via fault-tolerant readers, and add a non-null stream test. - [ ] **GPU-owned fault readback lifetime race (`DARNER_GPU_OWNED=1` / `DARNER_LAZY_BACK=1`)** (`crates/darner-gpu/src/gpu_owned.rs:583-605, 858-871`) `drop_range` and the failed-arming rollback clear bits/map entries without setting `gone` or taking `block_lock`, allowing a concurrent faulting thread to copy stale staging bytes into freed title memory and double-decrement `ACTIVE_COUNT`. **Fix:** Set `gone` before clearing bits, re-check under `block_lock`, and decrement only on successful swap. --- ## High (Compatibility, Hangs, Frame-Time Hitches) - [ ] **`GetProcAddress` diverges from static import resolution** (`crates/darner-hle/src/modules/kernel.rs:240-271`; `registry.rs:59-66`) `GetProcAddress` checks only the first module serving a DLL, never falls through to the host, and refuses ordinals—returning `NULL` for APIs that bind statically. **Fix:** Route pseudo-handles through `registry::lookup` + host policy, translate ordinal `n` to `"#n"`, and test parity with static binding. - [ ] **Wave64 census env mismatch & silent fallback when host wave is 0** (`apps/darner/src/translate.rs:283-287, 567-570`; `emit/lower.rs:1130-1136`; `host.rs:2484-2490`) `translate` reads `DARNER_HOST_MAX_WAVE` (not `DARNER_HOST_WAVE`), `precompile` sets neither, and failed `CheckFeatureSupport` leaves host wave at `0`—silently disabling Wave64 lowering and dropping shadows/water/particles. **Fix:** Alias/unify the env var, set it in `precompile`, and default unknown host wave to `32` with a warning. - [ ] **`SHADERS` mutex held across shader analysis & repeated container rescans** (`crates/darner-gpu/src/pipeline.rs:115-139`; `pipeline/make.rs:276-313, 348-360`) `SHADERS.lock()` is held during `ambient::role` / `mirror::part` analysis, and containers are re-scanned/re-decoded per pipeline creation, serializing title threads and hitching on new content. **Fix:** Look up under lock, analyze outside the lock, and memoize per-`Shader` classifications in `OnceLock`. - [ ] **HLE thread-lifetime crash & hang hazards** - `crates/darner-hle/src/mousehook.rs:247-250`: Stack/hook imbalance calls `std::process::abort()`; log once and return instead. - `crates/darner-hle/src/modules/xasync.rs:349-388`: A panic in `Timer::run`'s `job()` leaves `state.1 = true` forever, halting all delayed async completions; guard with `catch_unwind` or a `Drop` reset guard. - `crates/darner-hle/src/runtime.rs:25-32, 117-132`: `image_size` re-reads the PE header for every recorded image, risking a UAF if an entry outlives its mapping; cache `size_of_image` in `ImagePath` on registration. - `crates/darner-hle/src/modules/kernel.rs:122-127`: `GetModuleFileNameA` copies UTF-8 instead of the Windows ANSI code page; use `host::ansi`. --- ## Medium (Bookkeeping, Power-Loss Safety, Worker Resilience) - [ ] **`take_out` leaves stale `held` marks in descriptor queue** (`crates/darner-gpu/src/descriptor/host.rs:2107-2132, 2560-2564`) `take_out` clears `checked`/`mapped` but not `held`, keeping `has_held` elevated until a later `room()` pass. - [ ] **Pipeline cache publish skips `sync_all()` before `rename`** (`crates/darner-pipeline/src/cache.rs:144-154`) Power loss before flush can leave a partial file as a permanent bogus cache hit; call `sync_all()` before `rename` and evict entries that fail validation. - [ ] **Submission-path `.expect()` & silent texture-sweep thread death** (`crates/darner-gpu/src/host.rs:1039-1058, 3497`; `capture.rs:416-442`) `host.rs:3497` panics on prelude thread spawn failure (degrade to synchronous preludes); `host.rs:1045` stops idle texture reclaim forever if `let_go_idle()` panics (wrap in `catch_unwind`); `capture.rs` uses an unbounded channel and can spin on device removal. --- ## Low (Offline Test Coverage & Stale Docs) - [ ] **Folded-Wave64 & `s_getpc`/far-jump tests require an SM 6.6 GPU or private bench paths** (`crates/darner-shader/src/emit/folded_tests.rs:181-248`; `oracle64.rs:1876`; `fold.rs:1214-1225, 1650-1691`) Add default CPU tests using synthetic folded/far-branch programs verified against `oracle64::check_fold`. - [ ] **Stale-texture-upload race test is `#[ignore]`d** (`crates/darner-gpu/src/texture/ahead.rs:715-716`) Re-spawn the test binary with `--exact` and `DARNER_PRELUDE_UPLOADS=1` (matching `sampled.rs`) so `late_completion_keeps_a_newer_list_refresh` runs by default. - [ ] **Remove dead `DARNER_ORACLE_*` switches from `docs/shader-memory-validation.md:62`**

Static cross-check (source reading, no build)

I read the cited files on main (2026-12-05). 13 items: 5 confirmed, 8 partial, 0 outright not confirmed. A few citations are off, so the partial list is worth a second look.

Confirmed by code:

  • #1 analysis.rs:329-336 has 20 hashes in WIDE_SKIP_DEFAULT, including 34992f2b65a789a5; emit/mod.rs:1158-1163 suppresses the wave-wide form; pipeline.rs:209-215 drops the draws. This one is useful. Note: promoting exact64 to default still needs a visual check — exact64 with RT off has been reported to wash out the phone screen.
  • #2 pipeline/host.rs:241-248: NumElements/SemanticName unchecked.
  • #9 darner-pipeline/src/cache.rs:150-160: write -> drop -> rename, no sync_all.
  • #11 folded_tests.rs:181-185: needs SM 6.6; #12 texture/ahead.rs:715-716 is #[ignore]d.

Partial / citation corrections:

  • #7 kernel.rs:131 uses host::ansi, not UTF-8; the GetModuleFileNameA sub-claim is not true on main. The other three hazards look real.
  • #5 the DARNER_HOST_MAX_WAVE mismatch is real, but translate.rs:567-570 is progress_line and host.rs:2484-2490 is a test.
  • #6 pipeline.rs:115-139 holds SHADERS across ambient::role/mirror::part; make.rs:276-313 is left_out and :348-360 is Pending::new, so the "repeated rescans" part is not shown there.
  • #10 host.rs:3497 is the PlanePass comment, not a thread spawn.
  • #3/#4/#8/#13 are partial: the patterns exist, but the cited range/impact needs runtime or more code.

This is code-level only — no runtime reproduction. I can post the full 13-row table if useful.

## Static cross-check (source reading, no build) I read the cited files on `main` (2026-12-05). 13 items: **5 confirmed, 8 partial, 0 outright not confirmed**. A few citations are off, so the partial list is worth a second look. Confirmed by code: - **#1** `analysis.rs:329-336` has 20 hashes in `WIDE_SKIP_DEFAULT`, including `34992f2b65a789a5`; `emit/mod.rs:1158-1163` suppresses the wave-wide form; `pipeline.rs:209-215` drops the draws. This one is useful. Note: promoting exact64 to default still needs a visual check — exact64 with RT off has been reported to wash out the phone screen. - **#2** `pipeline/host.rs:241-248`: `NumElements`/`SemanticName` unchecked. - **#9** `darner-pipeline/src/cache.rs:150-160`: write -> drop -> rename, no `sync_all`. - **#11** `folded_tests.rs:181-185`: needs SM 6.6; **#12** `texture/ahead.rs:715-716` is `#[ignore]`d. Partial / citation corrections: - **#7** `kernel.rs:131` uses `host::ansi`, not UTF-8; the `GetModuleFileNameA` sub-claim is not true on `main`. The other three hazards look real. - **#5** the `DARNER_HOST_MAX_WAVE` mismatch is real, but `translate.rs:567-570` is `progress_line` and `host.rs:2484-2490` is a test. - **#6** `pipeline.rs:115-139` holds `SHADERS` across `ambient::role`/`mirror::part`; `make.rs:276-313` is `left_out` and `:348-360` is `Pending::new`, so the "repeated rescans" part is not shown there. - **#10** `host.rs:3497` is the `PlanePass` comment, not a thread spawn. - **#3/#4/#8/#13** are partial: the patterns exist, but the cited range/impact needs runtime or more code. This is code-level only — no runtime reproduction. I can post the full 13-row table if useful.
Contributor

I’m taking the texture-queue hold bookkeeping item. On c8258f9, take_out and put can leave the retired write recorded in held. The write ID check already protects queue eligibility. The heap flag can still keep sampled-feedback readback on the four-frame schedule after the last held write is removed or replaced, on the ordinary cadence path. Readback cadence

I’ll test retiring those marks on removal and replacement in both queue layouts, alongside an old completion arriving after a newer hold. #539 cuts the cost of collecting a queue snapshot and touches the same queue. This check is for the lifetime of the mark used outside the queue.

I’m taking the texture-queue hold bookkeeping item. On `c8258f9`, `take_out` and `put` can leave the retired write recorded in `held`. The write ID check already protects queue eligibility. The heap flag can still keep sampled-feedback readback on the four-frame schedule after the last held write is removed or replaced, on the ordinary cadence path. [Readback cadence](https://git.gtahub.st/TrustNo1/Darner/src/commit/c8258f95569c10fe75b5bfb785d3865b5deeefd9/crates/darner-gpu/src/sampled.rs#L234) I’ll test retiring those marks on removal and replacement in both queue layouts, alongside an old completion arriving after a newer hold. #539 cuts the cost of collecting a queue snapshot and touches the same queue. This check is for the lifetime of the mark used outside the queue.
Sign in to join this conversation.
No milestone
No project
No assignees
3 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#541
No description provided.