report: take a poisoned crash or write lock instead of losing the report #1705

Open
github-bot wants to merge 1 commit from github-bot/gh-1705 into main AGit
Owner

@⁠b3IKK on GitHub · 2026-11-24 19:27 UTC · original
b3IKK:report/poisoned-lock-keeps-crash-report → main · +30 −3 · 1 files · 1 commits · open

report::lock_within treats every try_lock error except WouldBlock as "give up":

Err(TryLockError::WouldBlock) if Instant::now() < end => sleep(...),
Err(_) => return None,

A poisoned lock is one a thread panicked while holding — exactly the situation a crash report exists for — yet it made write_final return before writing anything (WRITE_LOCK) and build drop the crash text (.ok() on CRASH). So a panic inside build() took the report with it, including the crash it was reporting.

This takes the poisoned guard with TryLockError::Poisoned(e) => Some(e.into_inner()) in lock_within, and reads CRASH through lock_within in build so the crash text is not silently dropped. A lock held by a live thread is still not waited for beyond wait, so a report from a thread already inside build() cannot wedge the process at exit.

What is in it

  • crates/xcl/src/report.rs: handle TryLockError::Poisoned in lock_within; read CRASH through it in build; add unit test a_poisoned_lock_is_taken_instead_of_losing_the_report (fails on main at expect("a poisoned lock is still taken")) and keep the held-lock timeout assertion.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 960 passed, 0 failed, 43 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib report::tests: 2 passed, 0 failed

Regression run

main (1d027e5, clean tree, no local changes):

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1645 (PresentX 1645)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14611 MB

PR (cf0cde2, clean tree, no local changes):

xcl-smoke v1
commit: cf0cde266bfadc6b41892b22845af096a4d13684
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1232 (PresentX 1232)
presents per 2 s (last 3): 2 2 17
device removals: 0
crashes: 0
peak commit: 24036 MB

(Two runs of this head: 1229 and 1232 frames. The change is in report.rs only — nothing on the render path — and XCL_TRANSLATOR_SOURCE_ID, which keys the translated-shader cache, does not include it; the minute went into the title's compute-pipeline work on this loaded box. No crashes and no device removals in either.)

Not tested

  • a title that actually panics inside build() (the unit test poisons the lock directly)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited report.rs, wrote the fix and unit test (and confirmed it fails without the fix), rebased onto 1d027e5, ran the test suite and scripts/smoke.ps1 regression runs with #677's title hashing, and drafted this PR description.
**@⁠b3IKK** on GitHub · 2026-11-24 19:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/1705) `b3IKK:report/poisoned-lock-keeps-crash-report` → `main` · +30 −3 · 1 files · 1 commits · open `report::lock_within` treats every `try_lock` error except `WouldBlock` as "give up": ```rust Err(TryLockError::WouldBlock) if Instant::now() < end => sleep(...), Err(_) => return None, ``` A **poisoned** lock is one a thread panicked while holding — exactly the situation a crash report exists for — yet it made `write_final` return before writing anything (`WRITE_LOCK`) and `build` drop the crash text (`.ok()` on `CRASH`). So a panic inside `build()` took the report with it, including the crash it was reporting. This takes the poisoned guard with `TryLockError::Poisoned(e) => Some(e.into_inner())` in `lock_within`, and reads `CRASH` through `lock_within` in `build` so the crash text is not silently dropped. A lock held by a live thread is still not waited for beyond `wait`, so a report from a thread already inside `build()` cannot wedge the process at exit. **What is in it** - `crates/xcl/src/report.rs`: handle `TryLockError::Poisoned` in `lock_within`; read `CRASH` through it in `build`; add unit test `a_poisoned_lock_is_taken_instead_of_losing_the_report` (fails on `main` at `expect("a poisoned lock is still taken")`) and keep the held-lock timeout assertion. **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 960 passed, 0 failed, 43 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, `no heap windows`, and `cannot disable the driver cache (Windows Developer Mode is required)`) - `cargo test -p xcl --lib report::tests`: 2 passed, 0 failed **Regression run** main (`1d027e5`, clean tree, no local changes): ``` xcl-smoke v1 commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1645 (PresentX 1645) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14611 MB ``` PR (`cf0cde2`, clean tree, no local changes): ``` xcl-smoke v1 commit: cf0cde266bfadc6b41892b22845af096a4d13684 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1232 (PresentX 1232) presents per 2 s (last 3): 2 2 17 device removals: 0 crashes: 0 peak commit: 24036 MB ``` (Two runs of this head: 1229 and 1232 frames. The change is in `report.rs` only — nothing on the render path — and `XCL_TRANSLATOR_SOURCE_ID`, which keys the translated-shader cache, does not include it; the minute went into the title's compute-pipeline work on this loaded box. No crashes and no device removals in either.) **Not tested** - a title that actually panics inside `build()` (the unit test poisons the lock directly) - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `report.rs`, wrote the fix and unit test (and confirmed it fails without the fix), rebased onto `1d027e5`, ran the test suite and `scripts/smoke.ps1` regression runs with #677's title hashing, and drafted this PR description.
lock_within treats every try_lock error but WouldBlock as "give up", so
a poisoned WRITE_LOCK (a thread that panicked inside build()) or CRASH
(a thread that panicked holding the crash text) made write_final return
before writing anything, and build() dropped the crash with .ok(). The
report a panic most needs to leave behind was the one it lost.

Take the poisoned guard (into_inner) for both, so the crash text and the
report are written anyway.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:09 +00:00
Author
Owner

@⁠b3IKK on GitHub · 2026-11-24 22:02 UTC · original

Rebased onto 1d027e5 and re-ran: 960 passed, 0 failed, 43 ignored; the blocks above use the current scripts/smoke.ps1 (#677's hashed itle: line). The PR block's frame count is lower than main's on this loaded box — the change is in
eport.rs only and is not part of the translated-shader cache key — but both runs show 0 crashes and 0 device removals.

**@⁠b3IKK** on GitHub · 2026-11-24 22:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7145724265) Rebased onto 1d027e5 and re-ran: 960 passed, 0 failed, 43 ignored; the blocks above use the current scripts/smoke.ps1 (#677's hashed itle: line). The PR block's frame count is lower than main's on this loaded box — the change is in eport.rs only and is not part of the translated-shader cache key — but both runs show 0 crashes and 0 device removals.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 22:09 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 22:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7145883136) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠throny on GitHub · 2026-11-25 00:37 UTC · original

Two contributors checked independently and found that #240 solves the same problem in a different way: #1607, group D65. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-25 00:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7148714340) <!-- xcl-1607-hint:D65 --> Two contributors checked independently and found that #240 solves the same problem in a different way: #1607, group D65. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 06:07 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 06:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7184121269) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1705/head:github-bot/gh-1705'
git switch 'github-bot/gh-1705'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1705'
git switch 'github-bot/gh-1705'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1705'
git switch 'github-bot/gh-1705'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1705'
git switch 'main'
git merge --squash 'github-bot/gh-1705'
git switch 'main'
git merge --ff-only 'github-bot/gh-1705'
git switch 'main'
git merge 'github-bot/gh-1705'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.