rdna2spirv: an out-of-range s_buffer_load reads through the buffer's base (llvmpipe segfault) #184

Closed
Andretuta wants to merge 6 commits from upstream-pr/184 into main
Andretuta commented 2026-11-24 02:37:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:37:32Z.


Carried over from old PR 9916 by LouisRiverstone in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9916, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
LouisRiverstone: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Problem. An out-of-range s_buffer_load segfaults llvmpipe, the CI's GPU. The translated code is correct: an s_buffer_load whose bound is only known at run time guards each dword with an OpSelectionMerge on off + 4·i + 4 <= NUM_RECORDS · stride and gives 0 outside it. llvmpipe (Mesa 26.0.8, LLVM 21.1.8) executes the guarded load anyway.

Found on #3039. Running its fixture cs_w32_late_ext on llvmpipe locally, vk_compute_test crashes with SIGSEGV (exit 139). Every 32-wide GPU passed it, because their stray read returns garbage that is thrown away. Word 6 is s12 = -4, offset:20: 0xFFFFFFFC + 20 = 0x100000010 bytes, past NUM_RECORDS = 0xFFFFFFFF, so it must read 0 (#1948). The guarded load at that address is 4 GB past the buffer.

Re-submission of #4573. #4573 was closed unmerged during the 2026-11-23 22:45 UTC cleanup, along with the other open PRs. This is the same branch, now merged with current main.

Checked on #4573 by: SweatierKey (Linux), kapitche (WSL2 Ubuntu), TreXito (Linux 6.18), cxchhh (Tesla V100-SXM2-32GB), Ayinaki (RTX 5070), tunczzz (RTX 5070 Ti), searyecheesepeaceful (610M), KkelebekK (780M), MatyEjsr (NVIDIA GeForce RTX 3090), lunarminus (760M), sovljanskii (Apple M4), Mortify7612 (AMD Radeon RX 9060 XT) and 3 more.

No game files.

AI-assisted (Claude Code): I reviewed the change and re-ran its tests on the merge with main.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465033617 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/184). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:37:32Z. --- > Carried over from **old PR 9916** by `LouisRiverstone` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9916`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `LouisRiverstone`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): **Problem.** An out-of-range `s_buffer_load` segfaults llvmpipe, the CI's GPU. The translated code is correct: an `s_buffer_load` whose bound is only known at run time guards each dword with an `OpSelectionMerge` on `off + 4·i + 4 <= NUM_RECORDS · stride` and gives 0 outside it. llvmpipe (Mesa 26.0.8, LLVM 21.1.8) executes the guarded load anyway. **Found on `#3039`.** Running its fixture `cs_w32_late_ext` on llvmpipe locally, `vk_compute_test` crashes with SIGSEGV (exit 139). Every 32-wide GPU passed it, because their stray read returns garbage that is thrown away. Word 6 is `s12 = -4, offset:20`: 0xFFFFFFFC + 20 = `0x100000010` bytes, past `NUM_RECORDS = 0xFFFFFFFF`, so it must read 0 (`#1948`). The guarded load at that address is 4 GB past the buffer. Re-submission of `#4573`. `#4573` was closed unmerged during the 2026-11-23 22:45 UTC cleanup, along with the other open PRs. This is the same branch, now merged with current `main`. Checked on `#4573` by: SweatierKey (Linux), kapitche (WSL2 Ubuntu), TreXito (Linux 6.18), cxchhh (Tesla V100-SXM2-32GB), Ayinaki (RTX 5070), tunczzz (RTX 5070 Ti), searyecheesepeaceful (610M), KkelebekK (780M), MatyEjsr (NVIDIA GeForce RTX 3090), lunarminus (760M), sovljanskii (Apple M4), Mortify7612 (AMD Radeon RX 9060 XT) and 3 more. No game files. AI-assisted (Claude Code): I reviewed the change and re-ran its tests on the merge with `main`.
aslan2142 commented 2026-11-24 19:19:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T19:19:03Z.


This carry-over of old upstream PR 9916 has been taken over in #650, so I'm closing this draft as #17 describes. The branch old-pr/9916 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7141918439 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/184#issuecomment-7141918439). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:19:03Z. --- This carry-over of old upstream PR 9916 has been taken over in #650, so I'm closing this draft as #17 describes. The branch `old-pr/9916` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

Sign in to join this conversation.
No reviewers
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
ProjectLeonida/mandy!184
No description provided.