shader: a lane mask that needs its own value fails instead of overflo… #43
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!43
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/43/head"
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?
@9hvn9yt2vk-netizen on GitHub · 2026-11-23 23:42 UTC · original
9hvn9yt2vk-netizen:shader-mask-cycle→main· +48 −1 · 2 files · 1 commits · merged 2026-11-24 00:34 UTC…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.
@DaviTostes on GitHub · 2026-11-23 23:51 UTC · original
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).
@tedin7 on GitHub · 2026-11-24 00:48 UTC · original
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).