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

Open
b3IKK wants to merge 1 commit from upstream-pr/1705 into main
b3IKK commented 2026-11-24 19:27:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T19:27:54Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5478880851 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T19:27:54Z. --- `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.
b3IKK commented 2026-11-24 22:06:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T22:02:34Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7145724265 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7145724265). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T22:02:34Z. --- 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.
DavidM1911 commented 2026-11-24 23:08:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T22:09:44Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7145883136 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7145883136). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T22:09:44Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
throny commented 2026-11-25 01:10:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:37:54Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7148714340 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7148714340). Originally posted by [throny](https://github.com/throny) on 2026-11-25T00:37:54Z. --- <!-- 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.
upstream-sync closed this pull request 2026-11-25 23:07:38 +00:00
CalvyPZ commented 2026-11-25 23:09:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:45:53Z.


This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.

<!-- greyfinch-sync:ivall/xcl:comment:7176760136 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7176760136). Originally posted by [CalvyPZ](https://github.com/CalvyPZ) on 2026-11-25T22:45:53Z. --- This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
upstream-sync reopened this pull request 2026-11-26 00:04:35 +00:00
DavidM1911 commented 2026-11-26 07:03:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T06:07:52Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7184121269 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7184121269). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T06:07:52Z. --- 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
github-actions[bot] commented 2026-11-30 08:43:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:43:05Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273255394 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7273255394). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:43:05Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:32:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:32:19Z.


Triage (#1607) – head cf0cde2

#240 also makes report::lock_within take a poisoned lock. It goes further: a thread-local re-entrancy guard, and fallback report writes made without WRITE_LOCK, which can race the thread that holds it. Its build() also reads CRASH with a blocking lock(). This PR is the minimal form (the poisoned branch, build() through lock_within with no wait, and a test). Neither is on main.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302988011 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1705#issuecomment-7302988011). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:32:19Z. --- **Triage (#1607)** – head cf0cde2 #240 also makes `report::lock_within` take a poisoned lock. It goes further: a thread-local re-entrancy guard, and fallback report writes made without `WRITE_LOCK`, which can race the thread that holds it. Its `build()` also reads `CRASH` with a blocking `lock()`. This PR is the minimal form (the poisoned branch, `build()` through `lock_within` with no wait, and a test). Neither is on main. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1705:upstream-pr/1705'
git switch 'upstream-pr/1705'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1705'
git switch 'upstream-pr/1705'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1705'
git switch 'upstream-pr/1705'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1705'
git switch 'main'
git merge --squash 'upstream-pr/1705'
git switch 'main'
git merge --ff-only 'upstream-pr/1705'
git switch 'main'
git merge 'upstream-pr/1705'
git push origin 'main'
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
xcl-dev/xcl!1695
No description provided.