Shaders: direct_sweep misclassifies translator panics as timeouts #2387

Open
opened 2026-11-26 05:29:47 +00:00 by github-bot · 1 comment
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-25 17:39 UTC · original

Summary

In crates/xcl/src/shaders.rs, direct_sweep runs coverage::translate_mode (lines 2068-2075) and recomp::lower_dxil::compute_with (lines 2080-2085) on a worker thread and waits on an mpsc channel with a timeout:

std::thread::spawn(move || {
    let _ = tx.send(coverage::translate_mode(&c, &m, o, validate));
});
rx.recv_timeout(timeout).unwrap_or_else(|_| Err(format!("timeout: over {} s", timeout.as_secs())))

When the translator panics inside the spawned thread, tx is dropped without sending a value, so rx.recv_timeout(timeout) returns Err(std::sync::mpsc::RecvTimeoutError::Disconnected) immediately. Because .unwrap_or_else(|_| ...) ignores the error variant, every translator panic is silently misreported as "timeout: over N s".

Suggested fix

Match RecvTimeoutError::Timeout and RecvTimeoutError::Disconnected separately in both places:

match rx.recv_timeout(timeout) {
    Ok(res) => res,
    Err(std::sync::mpsc::RecvTimeoutError::Timeout) => Err(format!("timeout: over {} s", timeout.as_secs())),
    Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => Err("panic: translator thread panicked".to_string()),
}

Not tested

  • Read from commit 082944135cd2b96288470a595861fa608eee08dc without a new runtime test.

AI use

  • Antigravity harness (Gemini 4 Neon) audited shaders.rs and drafted this report; the author reviewed it before posting.
**@⁠ahmetbagci8** on GitHub · 2026-11-25 17:39 UTC · [original](https://github.com/xcl-dev/xcl/issues/2387) ### Summary In `crates/xcl/src/shaders.rs`, `direct_sweep` runs `coverage::translate_mode` (lines 2068-2075) and `recomp::lower_dxil::compute_with` (lines 2080-2085) on a worker thread and waits on an `mpsc` channel with a timeout: ```rust std::thread::spawn(move || { let _ = tx.send(coverage::translate_mode(&c, &m, o, validate)); }); rx.recv_timeout(timeout).unwrap_or_else(|_| Err(format!("timeout: over {} s", timeout.as_secs()))) ``` When the translator panics inside the spawned thread, `tx` is dropped without sending a value, so `rx.recv_timeout(timeout)` returns `Err(std::sync::mpsc::RecvTimeoutError::Disconnected)` immediately. Because `.unwrap_or_else(|_| ...)` ignores the error variant, every translator panic is silently misreported as `"timeout: over N s"`. ### Suggested fix Match `RecvTimeoutError::Timeout` and `RecvTimeoutError::Disconnected` separately in both places: ```rust match rx.recv_timeout(timeout) { Ok(res) => res, Err(std::sync::mpsc::RecvTimeoutError::Timeout) => Err(format!("timeout: over {} s", timeout.as_secs())), Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => Err("panic: translator thread panicked".to_string()), } ``` ### Not tested - Read from commit `082944135cd2b96288470a595861fa608eee08dc` without a new runtime test. ### AI use - Antigravity harness (Gemini 4 Neon) audited `shaders.rs` and drafted this report; the author reviewed it before posting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:29:47 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 20:48 UTC · original

This is covered by #1997’s current head f053f279fe899f341cdfc9d0aa5e1de09cfbe116. Both the direct translator and per-lane worker call bounded_translation; it catches an unwind as panic: ... and maps a disconnected channel to panic: translation worker disconnected, while a real RecvTimeoutError::Timeout stays a timeout. That replaces both collapsed-error call sites described here.

#1997 is rebased onto current main, mergeable, and its Windows CI and PR-description checks are green. The focused shaders::tests run on the RX 6800M had 10 harness passes (one explicit driver-cache skip), including the panic/timeout worker test. This issue can close when #1997 merges; a separate #2387 patch would duplicate it.

AI use: OpenAI Codex (GPT-6; exact variant unavailable) compared the issue with the current PR code, ran the focused tests, and drafted this note.

**@⁠luckyteagirl** on GitHub · 2026-11-25 20:48 UTC · [original](https://github.com/xcl-dev/xcl/issues/2387#issuecomment-7174224488) This is covered by #1997’s current head `f053f279fe899f341cdfc9d0aa5e1de09cfbe116`. Both the direct translator and per-lane worker call `bounded_translation`; it catches an unwind as `panic: ...` and maps a disconnected channel to `panic: translation worker disconnected`, while a real `RecvTimeoutError::Timeout` stays a timeout. That replaces both collapsed-error call sites described here. #1997 is rebased onto current main, mergeable, and its Windows CI and PR-description checks are green. The focused `shaders::tests` run on the RX 6800M had 10 harness passes (one explicit driver-cache skip), including the panic/timeout worker test. This issue can close when #1997 merges; a separate #2387 patch would duplicate it. AI use: OpenAI Codex (GPT-6; exact variant unavailable) compared the issue with the current PR code, ran the focused tests, and drafted this note.
This discussion has been locked. Commenting is limited to contributors.
No description provided.