gpu: isolate AMD driver compiler crashes (crashed.txt) and skip self-CopyResource #2

Closed
jmal423 wants to merge 2 commits from upstream-pr/2 into main
jmal423 commented 2026-11-25 15:34:59 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by jmal423 on 2026-11-25T15:34:59Z.


Enables DexNom/VIctory to boot and run on AMD RDNA4 (tested on Windows 11 / AMD Radeon RX 9070 XT, Series X target) without crashing inside amdxc64.dll:

  • Per-pipeline driver crash isolation (crashed.txt): installs a Vectored Exception Handler around Create*PipelineState in pipeline::library that logs the failing pipeline hash, records it in crashed.txt (skipped on subsequent runs), and parks the faulting worker thread instead of crashing the process.
  • Automatic worker replacement: tracks parked worker threads via library::LOST and spawns replacement workers in pipeline::make::start so the pipeline worker pool never starves (preventing 12s/frame stalls when multiple PSOs fault in one session).
  • Skip self-CopyResource: skips CopyResource when to == from (same host texture).

Tested on Windows 11 / AMD Radeon RX 9070 XT:

  • Previously crashed ~3s after launch at amdxc64.dll+0x861b9f (0xc0000005, read 0x8).
  • With this patch, isolated the faulting RDNA4 pipelines into crashed.txt and ran in-game (both raster and experimental RT at 1.3-1.5 fps / 687-777 ms/frame in the prison scene).
<!-- greyfinch-sync:DexNom/VIctory:issue:5494397986 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2). Originally posted by [jmal423](https://github.com/jmal423) on 2026-11-25T15:34:59Z. --- Enables `DexNom/VIctory` to boot and run on AMD RDNA4 (tested on Windows 11 / AMD Radeon RX 9070 XT, Series X target) without crashing inside `amdxc64.dll`: - **Per-pipeline driver crash isolation (`crashed.txt`)**: installs a Vectored Exception Handler around `Create*PipelineState` in `pipeline::library` that logs the failing pipeline hash, records it in `crashed.txt` (skipped on subsequent runs), and parks the faulting worker thread instead of crashing the process. - **Automatic worker replacement**: tracks parked worker threads via `library::LOST` and spawns replacement workers in `pipeline::make::start` so the pipeline worker pool never starves (preventing 12s/frame stalls when multiple PSOs fault in one session). - **Skip self-`CopyResource`**: skips `CopyResource` when `to == from` (same host texture). Tested on Windows 11 / AMD Radeon RX 9070 XT: - Previously crashed ~3s after launch at `amdxc64.dll+0x861b9f` (`0xc0000005`, read `0x8`). - With this patch, isolated the faulting RDNA4 pipelines into `crashed.txt` and ran in-game (both raster and experimental RT at `1.3-1.5 fps` / `687-777 ms/frame` in the prison scene).
copilot-pull-request-reviewer[bot] commented 2026-11-25 15:35:08 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T15:35:08Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:DexNom/VIctory:review:6060607178 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060607178). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T15:35:08Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
DiegoStefanini commented 2026-11-25 15:45:55 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by DiegoStefanini on 2026-11-25T15:45:55Z.


Thanks for this! I merged it locally on top of current main (921d8d3), together with #1: no conflicts, clippy clean with and without --all-features, and the whole workspace test suite passes (623 passed, 0 failed) on an RTX 4060 Laptop. As expected it changes nothing on NVIDIA, since no driver crash happens there.

Two things I noticed while reading it:

  1. WAITING never comes back down after a parked worker. The worker that faults never returns from next().make(), so the WAITING.fetch_sub(1, …) in the worker loop never runs for that pipeline. After the first isolated crash, WAITING stays one too high for the rest of the session: drained() no longer fires (no "host pipelines all made" log, no library save on drain), and the pending count on the frame line stays above zero. Decrementing WAITING in compiler_crashed (next to LOST.fetch_add) before parking would keep the count right. The replacement worker then takes over the queue as it does now.

  2. Parking the thread inside the driver. The handler stops the faulting thread in the middle of Create*PipelineState, so whatever the driver's compiler held at that moment (an internal lock, for instance) stays held for good. If another Create*PipelineState on a replacement worker needs the same lock, that worker blocks too, and so on. It evidently didn't happen in your RDNA4 run, so this may be fine in practice. Still, a short note in the doc comment would help, and so would a log line when a replacement worker starts, so a stall like that is easy to recognise later.

Nothing else from me. The self-CopyResource skip and the spawn_worker refactor look good.

<!-- greyfinch-sync:DexNom/VIctory:comment:7167298909 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#issuecomment-7167298909). Originally posted by [DiegoStefanini](https://github.com/DiegoStefanini) on 2026-11-25T15:45:55Z. --- Thanks for this! I merged it locally on top of current `main` (921d8d3), together with #1: no conflicts, clippy clean with and without `--all-features`, and the whole workspace test suite passes (623 passed, 0 failed) on an RTX 4060 Laptop. As expected it changes nothing on NVIDIA, since no driver crash happens there. Two things I noticed while reading it: 1. **`WAITING` never comes back down after a parked worker.** The worker that faults never returns from `next().make()`, so the `WAITING.fetch_sub(1, …)` in the worker loop never runs for that pipeline. After the first isolated crash, `WAITING` stays one too high for the rest of the session: `drained()` no longer fires (no "host pipelines all made" log, no library save on drain), and the pending count on the frame line stays above zero. Decrementing `WAITING` in `compiler_crashed` (next to `LOST.fetch_add`) before parking would keep the count right. The replacement worker then takes over the queue as it does now. 2. **Parking the thread inside the driver.** The handler stops the faulting thread in the middle of `Create*PipelineState`, so whatever the driver's compiler held at that moment (an internal lock, for instance) stays held for good. If another `Create*PipelineState` on a replacement worker needs the same lock, that worker blocks too, and so on. It evidently didn't happen in your RDNA4 run, so this may be fine in practice. Still, a short note in the doc comment would help, and so would a log line when a replacement worker starts, so a stall like that is easy to recognise later. Nothing else from me. The self-`CopyResource` skip and the `spawn_worker` refactor look good.
itsonewi commented 2026-11-25 16:12:18 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by itsonewi on 2026-11-25T16:12:18Z.

Review: COMMENTED


probe from review endpoint

<!-- greyfinch-sync:DexNom/VIctory:review:6060976268 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060976268). Originally posted by [itsonewi](https://github.com/itsonewi) on 2026-11-25T16:12:18Z. **Review:** COMMENTED --- probe from review endpoint
itsonewi commented 2026-11-25 16:13:47 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by itsonewi on 2026-11-25T16:13:47Z.

Review: COMMENTED


Part 1 of a review of this patch against main (split up because the API kept failing on the long version).

The crashed name is never refused within the same run, so one broken pipeline crashes, parks and replaces in a loop.

crashed() reads crashed.txt once into a OnceLock<HashSet<String>>; note_crashed() only appends to the file and never touches that set. So in the run where the fault happens, crashed(name) is false for the rest of the run. A title that binds the same broken material pipeline every frame then repeats this: pipeline() -> not crashed -> create() -> the driver faults -> the VEH parks this worker and LOST += 1; the next make::start spawns a replacement that pops the next job, not the lost one; the next request for that name arrives and the cycle runs again.

Cost per attempt: one access violation, one log line, one permanently parked thread, one new thread. Unbounded over a session.

Fix: record the name in memory on the crash path as well (a Mutex<HashSet<String>> seeded once from the file, or a second OnceLock<Mutex<HashSet>>), so the second request in the same run returns Err immediately.

This is also the fix for the stall the description targets: the parked thread never sets made or left_out on the Pending it popped, so every frame that needs that pipeline waits its wait_budget (12 s per kind by default, pipeline/make.rs) for something that can no longer be made.


AI use: read the patch and crates/victory-gpu/src/pipeline/{make,library}.rs on main via the GitHub API; nothing built or run.

<!-- greyfinch-sync:DexNom/VIctory:review:6060987528 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060987528). Originally posted by [itsonewi](https://github.com/itsonewi) on 2026-11-25T16:13:47Z. **Review:** COMMENTED --- Part 1 of a review of this patch against `main` (split up because the API kept failing on the long version). **The crashed name is never refused within the same run, so one broken pipeline crashes, parks and replaces in a loop.** `crashed()` reads `crashed.txt` once into a `OnceLock<HashSet<String>>`; `note_crashed()` only appends to the file and never touches that set. So in the run where the fault happens, `crashed(name)` is `false` for the rest of the run. A title that binds the same broken material pipeline every frame then repeats this: `pipeline()` -> not crashed -> `create()` -> the driver faults -> the VEH parks this worker and `LOST += 1`; the next `make::start` spawns a replacement that pops the *next* job, not the lost one; the next request for that name arrives and the cycle runs again. Cost per attempt: one access violation, one log line, one permanently parked thread, one new thread. Unbounded over a session. Fix: record the name in memory on the crash path as well (a `Mutex<HashSet<String>>` seeded once from the file, or a second `OnceLock<Mutex<HashSet>>`), so the second request in the same run returns `Err` immediately. This is also the fix for the stall the description targets: the parked thread never sets `made` or `left_out` on the `Pending` it popped, so every frame that needs that pipeline waits its `wait_budget` (12 s per kind by default, `pipeline/make.rs`) for something that can no longer be made. --- **AI use:** read the patch and `crates/victory-gpu/src/pipeline/{make,library}.rs` on `main` via the GitHub API; nothing built or run.
itsonewi commented 2026-11-25 16:14:11 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by itsonewi on 2026-11-25T16:14:11Z.

Review: COMMENTED


Part 2 of the review (the rest, and one invariant worth writing down).

A parked thread leaves its Call entry behind. call() in library.rs pushes (thread, what, name, since) and removes it in Drop; a parked thread never drops it, so removal_note() reports make <pipeline> as a call running now for the rest of the run — which is exactly the report that diagnostic exists for.

crashed.txt never expires, and the README does not mention it. After a driver update that fixes the compiler the pipeline stays refused forever, and the only way out is finding and editing an undocumented file. A driver version or a date on the line, or one sentence in the README's known-issues list, would make it recoverable.

Confirmed on purpose, so that a later edit does not break it by accident: AddVectoredExceptionHandler(1, ...) returning 0 for exceptions that are not ours, the ExceptionInformation[1] >= 0x10000 filter, and the parking itself are free of the runtime's locks because create() runs outside them (// Compiled outside any lock), call() / one_call() / same_name() are scoped before it, and Pending::make compiles inside HostPipeline::new before touching DONE. That invariant deserves a line next to Making::new: moving any lock across create() would turn a parked thread into a deadlock that the replacement workers cannot repair.

Nothing here was built or run; this is from the patch and main.


AI use: read the patch and crates/victory-gpu/src/pipeline/{make,library}.rs on main via the GitHub API; nothing built or run.

<!-- greyfinch-sync:DexNom/VIctory:review:6060990486 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060990486). Originally posted by [itsonewi](https://github.com/itsonewi) on 2026-11-25T16:14:11Z. **Review:** COMMENTED --- Part 2 of the review (the rest, and one invariant worth writing down). **A parked thread leaves its `Call` entry behind.** `call()` in `library.rs` pushes `(thread, what, name, since)` and removes it in `Drop`; a parked thread never drops it, so `removal_note()` reports `make <pipeline>` as a call running now for the rest of the run — which is exactly the report that diagnostic exists for. **`crashed.txt` never expires, and the README does not mention it.** After a driver update that fixes the compiler the pipeline stays refused forever, and the only way out is finding and editing an undocumented file. A driver version or a date on the line, or one sentence in the README's known-issues list, would make it recoverable. **Confirmed on purpose, so that a later edit does not break it by accident:** `AddVectoredExceptionHandler(1, ...)` returning `0` for exceptions that are not ours, the `ExceptionInformation[1] >= 0x10000` filter, and the parking itself are free of the runtime's locks *because* `create()` runs outside them (`// Compiled outside any lock`), `call()` / `one_call()` / `same_name()` are scoped before it, and `Pending::make` compiles inside `HostPipeline::new` before touching `DONE`. That invariant deserves a line next to `Making::new`: moving any lock across `create()` would turn a parked thread into a deadlock that the replacement workers cannot repair. Nothing here was built or run; this is from the patch and `main`. --- **AI use:** read the patch and `crates/victory-gpu/src/pipeline/{make,library}.rs` on `main` via the GitHub API; nothing built or run.
manoel0810 commented 2026-11-25 16:29:33 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by manoel0810 on 2026-11-25T16:29:33Z.


Estava corrigindo exatamente isso! Estou testando aqui.

<!-- greyfinch-sync:DexNom/VIctory:comment:7168067137 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#issuecomment-7168067137). Originally posted by [manoel0810](https://github.com/manoel0810) on 2026-11-25T16:29:33Z. --- Estava corrigindo exatamente isso! Estou testando aqui.
jmal423 commented 2026-11-25 17:22:19 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by jmal423 on 2026-11-25T17:22:19Z.


Thanks for the thorough review @itsonewi! Updated the PR to address this:

  • Replaced OnceLock<HashSet<String>> with OnceLock<Mutex<HashSet<String>>> (crashed_set()), and note_crashed() now inserts into it in-memory via try_lock() as well as appending to crashed.txt, so repeated requests for a broken pipeline in the same run return Err immediately without re-faulting or parking more threads.
  • Documented the lock-free invariant above Making::new so future edits don't move any runtime lock across create().
<!-- greyfinch-sync:DexNom/VIctory:comment:7169406602 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#issuecomment-7169406602). Originally posted by [jmal423](https://github.com/jmal423) on 2026-11-25T17:22:19Z. --- Thanks for the thorough review @itsonewi! Updated the PR to address this: - Replaced `OnceLock<HashSet<String>>` with `OnceLock<Mutex<HashSet<String>>>` (`crashed_set()`), and `note_crashed()` now inserts into it in-memory via `try_lock()` as well as appending to `crashed.txt`, so repeated requests for a broken pipeline in the same run return `Err` immediately without re-faulting or parking more threads. - Documented the lock-free invariant above `Making::new` so future edits don't move any runtime lock across `create()`.
andrewDoing commented 2026-11-27 00:24:21 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by andrewDoing on 2026-11-27T00:24:21Z.


I checked the follow-up's same-run blacklist update at 13bad93 and found a contention case. Using the exact crashed_set, note_crashed, and crashed functions on Windows, one thread held the set lock while a second called note_crashed("contended"). The name was present on disk, but after the lock was released crashed("contended") returned false for the remainder of that process. An uncontended control returned true; a second process reloading the same file returned true for contended.

The try_lock failure appears to lose in-memory registration for the session; an ordinary concurrent crashed() lookup can hold that lock. Deferring failed registration for reconciliation outside the exception path, or documenting same-run updates as best effort, may be worth considering. No driver fault was induced and this makes no AMD-specific claim.

Verification was AI-assisted with GPT-6.2 Astra.

<!-- greyfinch-sync:DexNom/VIctory:comment:7206432884 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/2#issuecomment-7206432884). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-27T00:24:21Z. --- I checked the follow-up's same-run blacklist update at `13bad93` and found a contention case. Using the exact `crashed_set`, `note_crashed`, and `crashed` functions on Windows, one thread held the set lock while a second called `note_crashed("contended")`. The name was present on disk, but after the lock was released `crashed("contended")` returned false for the remainder of that process. An uncontended control returned true; a second process reloading the same file returned true for `contended`. The `try_lock` failure appears to lose in-memory registration for the session; an ordinary concurrent `crashed()` lookup can hold that lock. Deferring failed registration for reconciliation outside the exception path, or documenting same-run updates as best effort, may be worth considering. No driver fault was induced and this makes no AMD-specific claim. Verification was AI-assisted with GPT-6.2 Astra.

Pull request closed

Sign in to join this conversation.
No reviewers
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
DexNom/VIctory!2
No description provided.