BDA reads that cross a range boundary crash agc_driver_bda_device_tests on lavapipe #1044

Closed
opened 2026-10-07 03:09:50 +00:00 by NahuelGenchi · 8 comments
NahuelGenchi commented 2026-10-07 03:09:50 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-07T03:09:50Z.


agc_driver_bda_device_tests (tests/BdaDevice.cpp with tests/BdaExecution.cpp) is built but not registered in ctest, and on main (ab9437e3) it segfaults on lavapipe inside the JIT-compiled compute shader of RunBdaExecutionTests.

Adding a print before each run(...) shows the first two cases pass and the third one crashes:

run(guest, 8, 0x11, 0)            ok
run(guest + 1, 16, 0x3322, 0)     ok
run(guest + 1, 32, 0x55443322, 0) SIGSEGV in the shader (lavapipe worker thread)

That case is a 32-bit LoadAddressU32 at guest + 1 that straddles the two ranges of the test table: first covers guest .. guest + 3 with a 3-byte buffer and second covers guest + 3 .. guest + 5. The test expects the four bytes to be assembled from both buffers (0x22 0x33 from first, 0x44 0x55 from second). The crash suggests the generated code reads all four bytes through the pointer of the first range, which runs past the end of its 3-byte buffer. A real GPU may just read whatever follows in memory, so it could go unnoticed there, but the result would still be wrong for a read that crosses a range boundary.

The shader comes from the real BDA path (DefineGetBdaPointer and the LoadAddressU32 emitter in SpirvBackend), not hand-written test SPIR-V, so this looks like a product issue rather than a stale test. I haven't checked on hardware, and I couldn't tell whether cross-range reads are meant to be supported or should report a fault. If they're meant to work, this test is the reproduction, and registering it in ctest would catch regressions on lavapipe in CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5738742142 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044). Originally posted by [NahuelGenchi](https://github.com/NahuelGenchi) on 2026-10-07T03:09:50Z. --- `agc_driver_bda_device_tests` (`tests/BdaDevice.cpp` with `tests/BdaExecution.cpp`) is built but not registered in ctest, and on main (`ab9437e3`) it segfaults on lavapipe inside the JIT-compiled compute shader of `RunBdaExecutionTests`. Adding a print before each `run(...)` shows the first two cases pass and the third one crashes: ``` run(guest, 8, 0x11, 0) ok run(guest + 1, 16, 0x3322, 0) ok run(guest + 1, 32, 0x55443322, 0) SIGSEGV in the shader (lavapipe worker thread) ``` That case is a 32-bit `LoadAddressU32` at `guest + 1` that straddles the two ranges of the test table: `first` covers `guest .. guest + 3` with a 3-byte buffer and `second` covers `guest + 3 .. guest + 5`. The test expects the four bytes to be assembled from both buffers (`0x22 0x33` from `first`, `0x44 0x55` from `second`). The crash suggests the generated code reads all four bytes through the pointer of the first range, which runs past the end of its 3-byte buffer. A real GPU may just read whatever follows in memory, so it could go unnoticed there, but the result would still be wrong for a read that crosses a range boundary. The shader comes from the real BDA path (`DefineGetBdaPointer` and the `LoadAddressU32` emitter in `SpirvBackend`), not hand-written test SPIR-V, so this looks like a product issue rather than a stale test. I haven't checked on hardware, and I couldn't tell whether cross-range reads are meant to be supported or should report a fault. If they're meant to work, this test is the reproduction, and registering it in ctest would catch regressions on lavapipe in CI.
Adin-bima commented 2026-10-07 08:13:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Adin-bima on 2026-10-07T08:13:42Z.


Does not reproduce here on main 80d4f6b7: agc_driver_bda_device_tests passes 30/30 on lavapipe (Mesa 25.2.8, LLVM 20.1.2, forced with VK_DRIVER_FILES and confirmed llvmpipe via VK_LOADER_DEBUG), including the run(guest + 1, 32, 0x55443322, 0) case, and also passes on an RTX 5070 Ti (595.91.07). Could the crash depend on the Mesa/LLVM version in CI, or on where the 3-byte buffer is placed?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6033837893 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6033837893). Originally posted by [Adin-bima](https://github.com/Adin-bima) on 2026-10-07T08:13:42Z. --- Does not reproduce here on main 80d4f6b7: agc_driver_bda_device_tests passes 30/30 on lavapipe (Mesa 25.2.8, LLVM 20.1.2, forced with VK_DRIVER_FILES and confirmed llvmpipe via VK_LOADER_DEBUG), including the run(guest + 1, 32, 0x55443322, 0) case, and also passes on an RTX 5070 Ti (595.91.07). Could the crash depend on the Mesa/LLVM version in CI, or on where the 3-byte buffer is placed?
Dextroid17 commented 2026-10-07 11:34:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T11:34:58Z.


Adding a third data point, because it lands between the two of you and explains the disagreement.

It reproduces here, on main, with lavapipe Mesa 26.2.4 / LLVM 23.1.1:

$ ./build/tests/agc_driver_bda_device_tests
Segmentation fault (core dumped)        # exit 139, and nothing printed before it

So the matrix is now:

driver result
lavapipe Mesa 25.2.8 / LLVM 20.1.2 (@Adin-bima) passes 30/30
RTX 5070 Ti, 595.91.07 (@Adin-bima) passes
lavapipe Mesa 26.2.4 / LLVM 23.1.1 (here) SIGSEGV
@NahuelGenchi SIGSEGV

That makes it track the Mesa/LLVM version rather than the emitter being unconditionally wrong: the same generated shader passes on the older llvmpipe and on real hardware, and faults on the newer llvmpipe.

What the crash looks like under gdb:

Thread 33 "agc_driver_bda_" received signal SIGSEGV, Segmentation fault.
#0  0x00007ffff6495938 in ?? ()
#1  0x0000000000000000 in ?? ()

The fault is on an llvmpipe worker thread, and 0x7ffff6495938 is mapped — it falls inside an anonymous 0x7ffff6495000-0x7ffff64a2000 region, one of the 80 anonymous mappings in the process, i.e. the JIT'd shader rather than the test's own code. The frames above it are gone (return address 0), so this is the bottom of the fault, not an unwind through AnyPS5 code.

@NahuelGenchi's reading — a 32-bit load assembled through the first range's 3-byte pointer — is consistent with that, but the version split means I would not conclude the emitter is wrong from this alone. It could equally be llvmpipe 26.2.4/LLVM 23 mis-JITting the address arithmetic, which is what the older driver passing suggests.

On registering it in ctest: I would not do that unconditionally. The CI runner image's Mesa is a third version again, and this test proves the outcome swings with it — registering it as-is would make the Linux job fail or pass depending on the runner image, which is the kind of flake #1012/#1028 just went to some trouble to make visible. If it is worth running, it wants to be gated on the driver version, or run only where it is known to pass.

Happy to bisect the Mesa/LLVM axis further if that would settle which side is at fault — the package (vulkan-swrast 3:26.2.4) is a self-contained tarball, so several versions can be extracted side by side without touching the system.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6037056195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6037056195). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T11:34:58Z. --- Adding a third data point, because it lands between the two of you and explains the disagreement. **It reproduces here**, on `main`, with lavapipe **Mesa 26.2.4 / LLVM 23.1.1**: ``` $ ./build/tests/agc_driver_bda_device_tests Segmentation fault (core dumped) # exit 139, and nothing printed before it ``` So the matrix is now: | driver | result | | --- | --- | | lavapipe Mesa 25.2.8 / LLVM 20.1.2 (@Adin-bima) | passes 30/30 | | RTX 5070 Ti, 595.91.07 (@Adin-bima) | passes | | **lavapipe Mesa 26.2.4 / LLVM 23.1.1 (here)** | **SIGSEGV** | | @NahuelGenchi | SIGSEGV | That makes it track the **Mesa/LLVM version** rather than the emitter being unconditionally wrong: the same generated shader passes on the older llvmpipe and on real hardware, and faults on the newer llvmpipe. What the crash looks like under gdb: ``` Thread 33 "agc_driver_bda_" received signal SIGSEGV, Segmentation fault. #0 0x00007ffff6495938 in ?? () #1 0x0000000000000000 in ?? () ``` The fault is on an llvmpipe worker thread, and `0x7ffff6495938` **is** mapped — it falls inside an anonymous 0x7ffff6495000-0x7ffff64a2000 region, one of the 80 anonymous mappings in the process, i.e. the JIT'd shader rather than the test's own code. The frames above it are gone (return address 0), so this is the bottom of the fault, not an unwind through AnyPS5 code. @NahuelGenchi's reading — a 32-bit load assembled through the first range's 3-byte pointer — is consistent with that, but the version split means I would not conclude the emitter is wrong from this alone. It could equally be llvmpipe 26.2.4/LLVM 23 mis-JITting the address arithmetic, which is what the older driver passing suggests. **On registering it in ctest:** I would not do that unconditionally. The CI runner image's Mesa is a third version again, and this test proves the outcome swings with it — registering it as-is would make the Linux job fail or pass depending on the runner image, which is the kind of flake #1012/#1028 just went to some trouble to make visible. If it is worth running, it wants to be gated on the driver version, or run only where it is known to pass. Happy to bisect the Mesa/LLVM axis further if that would settle which side is at fault — the package (`vulkan-swrast` 3:26.2.4) is a self-contained tarball, so several versions can be extracted side by side without touching the system.
Dextroid17 commented 2026-10-07 14:29:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T14:29:39Z.


Reproduced deterministically — the variable is the driver's CPU-capability target, not the Mesa/LLVM version.

I can turn this crash on and off on one machine, one build, one SPIR-V, with GALLIUM_OVERRIDE_CPU_CAPS (lavapipe Mesa 26.2.4 / LLVM 23.1.1):

GALLIUM_OVERRIDE_CPU_CAPS result
avx (what CI sets) SIGSEGV, 10/10
sse2 SIGSEGV, 5/5
sse4_2 passes, 0/5
avx2 passes, 0/5
avx512f passes, 0/5
unset (native) passes, 0/200

That this is the driver and not the emitter is provable, not inferred: the module AnyPS5 emits is byte-identical under every one of those settings, because GALLIUM_OVERRIDE_CPU_CAPS is a Gallium variable and nothing in the tree reads it (grep -rn GALLIUM core/ tools/ is empty). Dumping the test's own shader under each setting:

avx / sse2 / sse4_2 / avx2 / avx512f -> sha256 477c7de6ac3bb76d, 15900 bytes

One module in, five behaviours out. The fault is in llvmpipe's generated code, not in what we hand it.

Which case, and where it faults. It is the third run — run(guest + 1, 32, 0x55443322, 0), the cross-range dword — as you reported; I confirmed it by printing before each run (the first two print, it dies on the third). In gdb:

Thread 21 "agc_driver_bda_" received signal SIGSEGV, Segmentation fault.
0x00007ffff6495938:  vpbroadcastd (%rcx),%ymm1        rcx=0

0x7ffff6495938 is inside one of the process's anonymous mappings — the JIT'd shader — and the load is from a null address, reached from llvmpipe's masked-gather lowering (vmovdqa %ymm3,0x860(%rsp) … mov 0x860(%rsp,%rsi,8),%rcx … vpbroadcastd (%rcx)).

On the two readings in the report. Both are ruled out by the above:

  • Not the emitter reading four bytes through the first range's 3-byte pointer. The emitter guards every byte load behind a non-null check (EmitBdaByte — the OpBranchConditional mapped in SpirvBdaRead.cpp), and the cross-range span does not even reach that path: probe_bda_pointer returns 0 for a span that leaves its range, so the byte fallback runs, and there all four bytes are mapped. The null llvmpipe loads through is one it manufactured.
  • Not the Mesa/LLVM version. @Adin-bima's pass on Mesa 25.2.8 and the crash here are the same difference as avx versus avx2 on this box: what decides it is the ISA llvmpipe compiles the shader for.

Localized to the probe. With APS5_BDA_BYTE_READS=1 — which omits probe_bda_pointer entirely — the same run passes under avx (0/5), while with the probe it segfaults 5/5. So it is llvmpipe's codegen for the probe's binary-search loop, not the byte loads.

Still live on main. I rebuilt agc_driver_bda_device_tests at 3c054008 (which includes #1043) and it is unchanged: avx and sse2 still segfault 5/5, the others pass, same instruction, same rcx=0.

On registering it in ctest. This is now the part that needs a decision, because CI sets exactly the crashing value. If the runner's llvmpipe shares this codegen, registering the test makes the Linux job fail deterministically — and #1012/#1028 exist precisely so a job does not report green while tests do not really run. I would not register it unconditionally; it wants a driver fix first, or a gate on the driver. I am filing the driver bug separately.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6040135420 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6040135420). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T14:29:39Z. --- **Reproduced deterministically — the variable is the driver's CPU-capability target, not the Mesa/LLVM version.** I can turn this crash on and off on one machine, one build, one SPIR-V, with `GALLIUM_OVERRIDE_CPU_CAPS` (lavapipe **Mesa 26.2.4 / LLVM 23.1.1**): | `GALLIUM_OVERRIDE_CPU_CAPS` | result | | --- | --- | | `avx` (what CI sets) | **SIGSEGV**, 10/10 | | `sse2` | **SIGSEGV**, 5/5 | | `sse4_2` | passes, 0/5 | | `avx2` | passes, 0/5 | | `avx512f` | passes, 0/5 | | unset (native) | passes, 0/200 | That this is the driver and not the emitter is provable, not inferred: the module AnyPS5 emits is **byte-identical** under every one of those settings, because `GALLIUM_OVERRIDE_CPU_CAPS` is a Gallium variable and nothing in the tree reads it (`grep -rn GALLIUM core/ tools/` is empty). Dumping the test's own shader under each setting: ``` avx / sse2 / sse4_2 / avx2 / avx512f -> sha256 477c7de6ac3bb76d, 15900 bytes ``` One module in, five behaviours out. The fault is in llvmpipe's generated code, not in what we hand it. **Which case, and where it faults.** It is the third `run` — `run(guest + 1, 32, 0x55443322, 0)`, the cross-range dword — as you reported; I confirmed it by printing before each `run` (the first two print, it dies on the third). In gdb: ``` Thread 21 "agc_driver_bda_" received signal SIGSEGV, Segmentation fault. 0x00007ffff6495938: vpbroadcastd (%rcx),%ymm1 rcx=0 ``` `0x7ffff6495938` is inside one of the process's anonymous mappings — the JIT'd shader — and the load is from a **null** address, reached from llvmpipe's masked-gather lowering (`vmovdqa %ymm3,0x860(%rsp)` … `mov 0x860(%rsp,%rsi,8),%rcx` … `vpbroadcastd (%rcx)`). **On the two readings in the report.** Both are ruled out by the above: - *Not the emitter reading four bytes through the first range's 3-byte pointer.* The emitter guards every byte load behind a non-null check (`EmitBdaByte` — the `OpBranchConditional mapped` in `SpirvBdaRead.cpp`), and the cross-range span does not even reach that path: `probe_bda_pointer` returns 0 for a span that leaves its range, so the byte fallback runs, and there all four bytes are mapped. The null llvmpipe loads through is one it manufactured. - *Not the Mesa/LLVM version.* @Adin-bima's pass on Mesa 25.2.8 and the crash here are the same difference as `avx` versus `avx2` on this box: what decides it is the ISA llvmpipe compiles the shader for. **Localized to the probe.** With `APS5_BDA_BYTE_READS=1` — which omits `probe_bda_pointer` entirely — the same run **passes** under `avx` (0/5), while with the probe it segfaults 5/5. So it is llvmpipe's codegen for the probe's binary-search loop, not the byte loads. **Still live on `main`.** I rebuilt `agc_driver_bda_device_tests` at `3c054008` (which includes #1043) and it is unchanged: `avx` and `sse2` still segfault 5/5, the others pass, same instruction, same `rcx=0`. **On registering it in ctest.** This is now the part that needs a decision, because CI sets exactly the crashing value. If the runner's llvmpipe shares this codegen, registering the test makes the Linux job fail deterministically — and #1012/#1028 exist precisely so a job does not report green while tests do not really run. I would not register it unconditionally; it wants a driver fix first, or a gate on the driver. I am filing the driver bug separately.
Dextroid17 commented 2026-10-07 16:00:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T16:00:27Z.


Following up my previous comment: the driver bug is filed upstream as mesa/mesa#16515, and because the crash reproduces from the dumped shader alone I packaged it self-contained — the test's .spv plus a ~250-line Vulkan harness, no AnyPS5 code:

https://github.com/Dextroid17/llvmpipe-caps-crash

The harness takes the SPIR-V module and runs it under GALLIUM_OVERRIDE_CPU_CAPS, so the driver-side claim is checkable without this tree (avx/sse2 → SIGSEGV, sse4_2/avx2/avx512 → output 0x55443322, identical module every time).

That is also the answer to the ctest question for now: register agc_driver_bda_device_tests only after the driver is fixed, or behind a gate, since CI sets exactly the crashing GALLIUM_OVERRIDE_CPU_CAPS=avx. Registering it as-is would make the Linux job fail deterministically on this codegen.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6041700117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6041700117). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T16:00:27Z. --- Following up my previous comment: the driver bug is filed upstream as **mesa/mesa#16515**, and because the crash reproduces from the dumped shader alone I packaged it self-contained — the test's `.spv` plus a ~250-line Vulkan harness, no AnyPS5 code: https://github.com/Dextroid17/llvmpipe-caps-crash The harness takes the `SPIR-V` module and runs it under `GALLIUM_OVERRIDE_CPU_CAPS`, so the driver-side claim is checkable without this tree (`avx`/`sse2` → SIGSEGV, `sse4_2`/`avx2`/`avx512` → output `0x55443322`, identical module every time). That is also the answer to the ctest question for now: register `agc_driver_bda_device_tests` only after the driver is fixed, or behind a gate, since CI sets exactly the crashing `GALLIUM_OVERRIDE_CPU_CAPS=avx`. Registering it as-is would make the Linux job fail deterministically on this codegen.
polysius commented 2026-10-07 17:51:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by polysius on 2026-10-07T17:51:58Z.


I looked into this, and I think the crash is a lavapipe bug rather than a read through the wrong range.

Setup. A debug branch on my fork builds only agc_driver_bda_device_tests on ubuntu-latest and runs it on the lavapipe CI installs: Mesa 25.2.8-0ubuntu0.24.04.4, with GALLIUM_OVERRIDE_CPU_CAPS=avx. I also ran the same binary on a Qualcomm Adreno X1-45 (Windows, MinGW GCC 15.2.0). Every variant below changes only EmitBdaDwordReads, behind a debug switch. Results for run(guest + 1, 32, 0x55443322):

Variant lavapipe 25.2.8 Adreno X1-45
main SIGSEGV in the JIT code (rax = rcx = rdx = rsi = 0) passes
APS5_BDA_BYTE_READS=1 (no probe) passes passes
probe result written to the output instead of reading 0, as expected for a span that crosses ranges 0
wide branch kept, its loads replaced by constants passes —
wide pointer = probe result AND a zero loaded from the table at run time SIGSEGV passes
bdaStopsInvocations = false (no early return in the byte path) SIGSEGV —
Volatile on the wide loads SIGSEGV —

So the probe returns 0, mapped && aligned is false, and the shader still faults whenever the untaken branch contains a load through that null pointer. The SPIR-V only loads through it under that condition, so nothing should be dereferenced. #1043 reports these cases passing on NVIDIA and on Mesa 26.2.4 lavapipe on Windows.

What lavapipe does. In visit_load_global (src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c), a load whose address divergence analysis marks uniform becomes a scalar load with no exec-mask check. Small if-sides are flattened by lp_should_flatten_cf_list, so they run under the mask without a real branch. Here the address is uniform and the wide side is small, so the load runs with the mask empty.

This came in with a57e8b2e (!32963, Mesa 25.1). It's still open upstream:

  • mesa#15667: a conditional load executed unconditionally, on 26.1.2.
  • mesa#16217: a BDA pointer dereferenced in a loop that never runs, on 26.2.1.
  • !42326: an unmerged one-line fix.

The code path is the same in 26.2.4, so the pass there is probably a different NIR shape, not a fix.

Options I see:

  1. Keep agc_driver_bda_device_tests out of ctest until CI's lavapipe has the fix.
  2. Register it and skip the probed cross-range cases on lavapipe (exit 77), with a TechnicalDebt line naming the Mesa issue.
  3. Never let the wide branch's pointer be invalid. Select a valid fallback before OpSelectionMerge, e.g. OpSelect(wide, physical, dummy), as mesa#16217 suggests. That needs a device address the shader can always read, such as a zero page the host adds to the BDA table. That's an ABI change, and it would also protect titles' BDA reads on lavapipe.

Which would you prefer? I can send a PR for any of them.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6043627522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6043627522). Originally posted by [polysius](https://github.com/polysius) on 2026-10-07T17:51:58Z. --- I looked into this, and I think the crash is a lavapipe bug rather than a read through the wrong range. **Setup.** A debug branch on my fork builds only `agc_driver_bda_device_tests` on `ubuntu-latest` and runs it on the lavapipe CI installs: Mesa `25.2.8-0ubuntu0.24.04.4`, with `GALLIUM_OVERRIDE_CPU_CAPS=avx`. I also ran the same binary on a Qualcomm Adreno X1-45 (Windows, MinGW GCC 15.2.0). Every variant below changes only `EmitBdaDwordReads`, behind a debug switch. Results for `run(guest + 1, 32, 0x55443322)`: | Variant | lavapipe 25.2.8 | Adreno X1-45 | |---|---|---| | `main` | SIGSEGV in the JIT code (`rax = rcx = rdx = rsi = 0`) | passes | | `APS5_BDA_BYTE_READS=1` (no probe) | passes | passes | | probe result written to the output instead of reading | `0`, as expected for a span that crosses ranges | `0` | | wide branch kept, its loads replaced by constants | passes | — | | wide pointer = probe result AND a zero loaded from the table at run time | SIGSEGV | passes | | `bdaStopsInvocations = false` (no early return in the byte path) | SIGSEGV | — | | `Volatile` on the wide loads | SIGSEGV | — | So the probe returns 0, `mapped && aligned` is false, and the shader still faults whenever the untaken branch contains a load through that null pointer. The SPIR-V only loads through it under that condition, so nothing should be dereferenced. #1043 reports these cases passing on NVIDIA and on Mesa 26.2.4 lavapipe on Windows. **What lavapipe does.** In `visit_load_global` (`src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c`), a load whose address divergence analysis marks uniform becomes a scalar load with no exec-mask check. Small if-sides are flattened by `lp_should_flatten_cf_list`, so they run under the mask without a real branch. Here the address is uniform and the wide side is small, so the load runs with the mask empty. This came in with a57e8b2e (!32963, Mesa 25.1). It's still open upstream: - [mesa#15667](https://gitlab.freedesktop.org/mesa/mesa/-/issues/15667): a conditional load executed unconditionally, on 26.1.2. - [mesa#16217](https://gitlab.freedesktop.org/mesa/mesa/-/issues/16217): a BDA pointer dereferenced in a loop that never runs, on 26.2.1. - [!42326](https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42326): an unmerged one-line fix. The code path is the same in 26.2.4, so the pass there is probably a different NIR shape, not a fix. **Options I see:** 1. Keep `agc_driver_bda_device_tests` out of ctest until CI's lavapipe has the fix. 2. Register it and skip the probed cross-range cases on lavapipe (exit 77), with a TechnicalDebt line naming the Mesa issue. 3. Never let the wide branch's pointer be invalid. Select a valid fallback before `OpSelectionMerge`, e.g. `OpSelect(wide, physical, dummy)`, as mesa#16217 suggests. That needs a device address the shader can always read, such as a zero page the host adds to the BDA table. That's an ABI change, and it would also protect titles' BDA reads on lavapipe. Which would you prefer? I can send a PR for any of them. AI-assisted: yes.
polysius commented 2026-10-07 17:53:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by polysius on 2026-10-07T17:53:38Z.


Sorry, I posted that without seeing @Dextroid17's comments above. You had already shown this is driver-side and filed mesa/mesa#16515.

Two corrections to mine:

  • My mechanism paragraph doesn't fit your CPU-caps result. The uniform scalar load path I described doesn't depend on the target ISA, but here the same module crashes with avx/sse2 and passes with sse4_2/avx2/avx512. Together with the mov 0x860(%rsp,%rsi,8),%rcx; vpbroadcastd (%rcx) sequence, that points at the per-lane masked-gather lowering, so please treat my explanation as unconfirmed.
  • My variants do localize the fault more narrowly than the probe loop. On lavapipe the probe's binary search returns the right value (0), and the crash goes away when only the loads in the untaken mapped && aligned branch are replaced by constants. So the faulting load is the wide-branch load through the probe's null result, run under an empty mask.

mesa#16217 (a BDA pointer dereferenced in a loop that never runs) and mesa#15667 might be the same bug as #16515, if that helps upstream.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6043654878 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6043654878). Originally posted by [polysius](https://github.com/polysius) on 2026-10-07T17:53:38Z. --- Sorry, I posted that without seeing @Dextroid17's comments above. You had already shown this is driver-side and filed mesa/mesa#16515. Two corrections to mine: - My mechanism paragraph doesn't fit your CPU-caps result. The uniform scalar load path I described doesn't depend on the target ISA, but here the same module crashes with `avx`/`sse2` and passes with `sse4_2`/`avx2`/`avx512`. Together with the `mov 0x860(%rsp,%rsi,8),%rcx; vpbroadcastd (%rcx)` sequence, that points at the per-lane masked-gather lowering, so please treat my explanation as unconfirmed. - My variants do localize the fault more narrowly than the probe loop. On lavapipe the probe's binary search returns the right value (0), and the crash goes away when only the loads in the untaken `mapped && aligned` branch are replaced by constants. So the faulting load is the wide-branch load through the probe's null result, run under an empty mask. mesa#16217 (a BDA pointer dereferenced in a loop that never runs) and mesa#15667 might be the same bug as #16515, if that helps upstream.
oneandonlydean commented 2026-10-08 08:26:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T08:26:21Z.


Closing: the shader is valid and passes everywhere except lavapipe with the avx/sse2 CPU caps, so it's the driver (mesa/mesa#16515). The test can be registered once Mesa fixes it; comment here if it fails on another driver.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055871086 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6055871086). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T08:26:21Z. --- Closing: the shader is valid and passes everywhere except lavapipe with the `avx`/`sse2` CPU caps, so it's the driver (mesa/mesa#16515). The test can be registered once Mesa fixes it; comment here if it fails on another driver.
MarcZX10 commented 2026-10-09 20:23:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T20:23:55Z.


I carried the focused cross-range regression test onto current main in fork branch codex/fix-bda-cross-range-timeout, without opening a PR.

The test is registered separately as agc_bda_cross_range, has a 30-second timeout, and returns CTest's skip code on CPU Vulkan devices. This avoids running the known lavapipe CPU-cap case described above; on a hardware Vulkan device it exercises the cross-range shader path. The target builds locally and conventions pass. On this host CTest reports the test as skipped because only a CPU Vulkan device is available, so I have not validated the cross-range read on GPU hardware.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088646859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1044#issuecomment-6088646859). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T20:23:55Z. --- I carried the focused cross-range regression test onto current `main` in fork branch [`codex/fix-bda-cross-range-timeout`](https://github.com/MarcZX100/AnyPS5/tree/codex/fix-bda-cross-range-timeout), without opening a PR. The test is registered separately as `agc_bda_cross_range`, has a 30-second timeout, and returns CTest's skip code on CPU Vulkan devices. This avoids running the known lavapipe CPU-cap case described above; on a hardware Vulkan device it exercises the cross-range shader path. The target builds locally and conventions pass. On this host CTest reports the test as skipped because only a CPU Vulkan device is available, so I have **not** validated the cross-range read on GPU hardware.
Sign in to join this conversation.
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
boykopovar/AnyPS5#1044
No description provided.