Repository navigation
shader: a lane mask that needs its own value fails instead of overflo… - #43
Merged
Merged
Conversation
…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.
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
Contributor
|
checked: PR head Ran (shader crate only, so I did not hit the
Review notes:
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). |
suirentakamura
referenced
this pull request
in suirentakamura/victory-suiren
Nov 24, 2026
shader: a lane mask that needs its own value fails instead of overflo…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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.