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

Closed
opened 2026-11-26 20:17:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/184
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/9916


📝 Commits (6)

  • 6c91f85 rdna2spirv: an out-of-range s_buffer_load is loaded with no branch, from the V# base (llvmpipe segfault)
  • f5caa21 scalar_load: out of range, the branchless s_buffer_load reads the heap base, not the V# base
  • d47a4a5 Merge remote-tracking branch 'origin/main' into HEAD
  • 4affd83 Merge remote-tracking branch 'origin/main' into HEAD
  • e168cbb Merge remote-tracking branch 'origin/main' into HEAD
  • 98cefe9 Merge remote-tracking branch 'origin/main' into HEAD

📊 Changes

8 files changed (+313 additions, -28 deletions)

View changed files

📝 docs/design.md (+1 -0)
📝 runtime/test/shaders/check.py (+3 -1)
➕ runtime/test/shaders/cs_smem_oob_far.asm (+73 -0)
📝 scripts/run_gpu_tests.py (+4 -2)
➕ tests/semantic/fixtures/disasm/cs_smem_oob_far.s (+55 -0)
📝 tests/semantic/test_scalar_mem_smem.py (+15 -1)
➕ tests/semantic/test_smem_oob_safe_address.py (+144 -0)
📝 tools/rdna2spirv.py (+18 -24)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/184 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9916` --- ### 📝 Commits (6) - [`6c91f85`](https://github.com/ubiquitarianism/leonida/commit/6c91f851fed011b94f513f0b03cdaf5b010760e7) rdna2spirv: an out-of-range s_buffer_load is loaded with no branch, from the V# base (llvmpipe segfault) - [`f5caa21`](https://github.com/ubiquitarianism/leonida/commit/f5caa216386438887097d5438ac58fac81b53ce2) scalar_load: out of range, the branchless s_buffer_load reads the heap base, not the V# base - [`d47a4a5`](https://github.com/ubiquitarianism/leonida/commit/d47a4a533dd2e6dfe8e1f836978ea86093338367) Merge remote-tracking branch 'origin/main' into HEAD - [`4affd83`](https://github.com/ubiquitarianism/leonida/commit/4affd830b79ab4726733bc1b53eae1884dcee53c) Merge remote-tracking branch 'origin/main' into HEAD - [`e168cbb`](https://github.com/ubiquitarianism/leonida/commit/e168cbb9656d4105ff9dfe369c5f0e1f9b95e1d2) Merge remote-tracking branch 'origin/main' into HEAD - [`98cefe9`](https://github.com/ubiquitarianism/leonida/commit/98cefe9b08e4d868f610415ab798932ab3b59ff8) Merge remote-tracking branch 'origin/main' into HEAD ### 📊 Changes **8 files changed** (+313 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) 📝 `runtime/test/shaders/check.py` (+3 -1) ➕ `runtime/test/shaders/cs_smem_oob_far.asm` (+73 -0) 📝 `scripts/run_gpu_tests.py` (+4 -2) ➕ `tests/semantic/fixtures/disasm/cs_smem_oob_far.s` (+55 -0) 📝 `tests/semantic/test_scalar_mem_smem.py` (+15 -1) ➕ `tests/semantic/test_smem_oob_safe_address.py` (+144 -0) 📝 `tools/rdna2spirv.py` (+18 -24) </details> ### 📄 Description > 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`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:13 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#237
No description provided.