Shaders: direct_sweep misclassifies translator panics as timeouts #2377

Open
opened 2026-11-25 17:39:19 +00:00 by ahmetbagci8 · 1 comment
ahmetbagci8 commented 2026-11-25 17:39:19 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by ahmetbagci8 on 2026-11-25T17:39:19Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:6610197444 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2387). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-11-25T17:39:19Z. --- ### 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.
luckyteagirl commented 2026-11-25 21:05:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T20:48:54Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7174224488 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2387#issuecomment-7174224488). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T20:48:54Z. --- 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.
Sign in to join this conversation.
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#2377
No description provided.