shader: a lane mask that needs its own value fails instead of overflo… #43
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/43"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by 9hvn9yt2vk-netizen on 2026-11-23T23:42:55Z.
…wing the stack
In a wave64 compute program, writing only EXEC's high dword (for example s_mov_b32 exec_hi, 0) and then running any vector instruction crashed the whole process with a stack overflow. The new mask is opaque and keyed by the unchanged low dword, so lowering the instruction's guard asked for that dword's value, the value is a lane mask read as data, its ballot needs the mask's lane bit, and that bit needs the value again: mask_dword -> boolean -> atom -> get -> mask_dword, without end.
mask_dword now notes the masks whose ballot it is building, and a mask reached again on the way fails with a reason. The instruction then fails like any other that cannot be expressed: its result is missing, and only a side effect that uses it stops the translation. A shader the translator cannot handle must not take the title down at pipeline creation.
Found with a random-input harness over the whole translation (ir, resource, io, structure, emit) of random decodable compute programs. The new test overflows the stack without the fix. One million further programs (about 160,000 fully translated) gave no panic, hang or overflow.
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-23T23:51:42Z.
Tested
ea24ea1stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.mainalone does not build on Linux (E0425 invictory-gpu), so the check uses #39 as the base; the merge is clean.cargo test --workspace: 156 passed, 0 failed, 3 ignored.an_exec_high_write_does_not_overflow_the_stacktest runs and passes; no other test changed. No game data used.AI-assisted (DeepSeek V4.1 Flash coding agent).
Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:48:02Z.
checked: PR head
ea24ea1on its merge-base97c78d1, Linux x86_64 (Debian, kernel 6.12), rustc/cargo 1.98.1, throwaway worktree, no game files used. This was run while the PR was being merged (it shows merged at 00:34 UTC), so it is a record, not a gate.Ran (shader crate only, so I did not hit the
victory-gpubuild error mentioned above):cargo test -j4 -p victory-shader: 52 passed, 0 failed, includingan_exec_high_write_does_not_overflow_the_stack.cargo clippy -j4 -p victory-shader --tests: no new warnings (theconstant_color is never usedtest-module warning also appears on trees that do not touchemit/mod.rs).lower.rsreverted to97c78d1and the new test kept,cargo test -p victory-shader an_exec_highends withthread ... has overflowed its stack, fatal runtime error: stack overflow, SIGABRT. With the fix it passes. So the test does guard the fix.Review notes:
boolean, removed on both the Ok and Err path (let bit = ...; remove; bit?), so an error does not leave a stale entry that would block a later legitimate lookup.emitreturnsOk(())with the fix (I printed it temporarily). So theif let Err(e)branch, with its "its own value" message assertion, never runs; the test effectively proves "no crash" only. That is the important part. If you want the message pinned, a program whose side effect uses the failing instruction's result would hit theErrbranch.victory-shadertest run.Not verified: Windows runtime, GPU, or the random-input harness the description mentions (it is not in the tree, so I could not rerun the "one million programs" claim).