vk_compute_test: VKC_HEAP_FILE refuses an offset of 2^32 and a file past the 4 GiB heap (RT-439) (OLD-9943) #670

Manually merged
github merged 1 commit from gh-pr/670/head into gh-pr/670/base 2026-11-26 09:15:15 +00:00
Owner

@⁠LouisRiverstone on GitHub · 2026-11-24 11:19 UTC · original
LouisRiverstone:carry-old-9943 → main · +21 −5 · 1 files · 1 commits · merged 2026-11-24 16:39 UTC

Claimed in the coordination issue as: OLD-9943 (#14)

Replaces the carried-over draft #210. I'm the original author of old upstream PR 9943.

What and why

RT-439. VKC_HEAP_FILE=<path>[@<offset>] accepted the offset 2^32, which is one byte past the 32-bit heap. It also read the whole file without checking that it fits below 2^32 from that offset. Now the offset must be below 2^32. The file's size is checked on the open file before anything is read, so a file too large for the heap is refused without being loaded into memory (pointed out by shdann on the old PR). An empty or unreadable file is still refused, with the same message as before.

The old branch's final diff, applied on current main (21625bca8) as one commit. It applied cleanly.

Tested

Built vk_compute_test on Linux (GCC, cmake -S runtime, RelWithDebInfo) and ran it with synthetic files:

  • f16.bin@0x100000000 is refused: expected <path>[@<offset>]
  • 16 bytes at 0xFFFFFFF8 is refused: runs past the 4 GiB heap
  • a 5 GiB sparse file at @0 is refused before any read: runs past the 4 GiB heap
  • an empty file and a missing file are both refused: cannot read
  • 16 bytes at 0xFFFFFFF0, which ends exactly at 2^32, passes the check. The run then stops at vkCreateBuffer for the 4 GiB heap on llvmpipe (-2, out of host memory), which is a limit of this machine.

No GPU run.

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: test tool only)
**@⁠LouisRiverstone** on GitHub · 2026-11-24 11:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/670) `LouisRiverstone:carry-old-9943` → `main` · +21 −5 · 1 files · 1 commits · merged 2026-11-24 16:39 UTC Claimed in the coordination issue as: OLD-9943 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Replaces the carried-over draft #210. I'm the original author of old upstream PR 9943. ### What and why RT-439. `VKC_HEAP_FILE=<path>[@<offset>]` accepted the offset 2^32, which is one byte past the 32-bit heap. It also read the whole file without checking that it fits below 2^32 from that offset. Now the offset must be below 2^32. The file's size is checked on the open file before anything is read, so a file too large for the heap is refused without being loaded into memory (pointed out by shdann on the old PR). An empty or unreadable file is still refused, with the same message as before. The old branch's final diff, applied on current `main` (21625bca8) as one commit. It applied cleanly. ### Tested Built `vk_compute_test` on Linux (GCC, `cmake -S runtime`, RelWithDebInfo) and ran it with synthetic files: - `f16.bin@0x100000000` is refused: `expected <path>[@<offset>]` - 16 bytes at `0xFFFFFFF8` is refused: `runs past the 4 GiB heap` - a 5 GiB sparse file at `@0` is refused before any read: `runs past the 4 GiB heap` - an empty file and a missing file are both refused: `cannot read` - 16 bytes at `0xFFFFFFF0`, which ends exactly at 2^32, passes the check. The run then stops at `vkCreateBuffer` for the 4 GiB heap on llvmpipe (`-2`, out of host memory), which is a limit of this machine. No GPU run. GPUs tested: n/a AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: test tool only)
- vk_compute_test: VKC_HEAP_FILE refuses an offset of 2^32 and a file that runs past the 4 GiB heap (RT-439)
- vk_compute_test: check VKC_HEAP_FILE's size on the open file before reading it (old PR 5878)

Carried over from old-pr/9943 (old upstream PR 9943), rebased on main.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:15:14 +00:00
github manually merged commit 55b5d737f5 into gh-pr/670/base 2026-11-26 09:15:15 +00:00
Author
Owner

@⁠trigger337 on GitHub · 2026-11-24 11:32 UTC · original

Hardware verification on AMD Radeon RX 6900 XT (RADV Navi 21, Mesa 26.2.5, Linux CachyOS, Vulkan 1.4.333):

  • Built vk_compute_test on Linux with GCC/CMake.
  • Verified error handling cases with synthetic files:
    • Offset ^{32}$ (16b.bin@0x100000000): refused with expected <path>[@<offset>] (exit 2).
    • 16 bytes at 0xFFFFFFF8: refused with runs past the 4 GiB heap (exit 2).
    • 5 GiB sparse file at @0: refused before memory read via tellg() check with runs past the 4 GiB heap (exit 2).
    • Empty and non-existent files: refused with cannot read (exit 2).
  • Hardware execution test: 16 bytes at 0xFFFFFFF0 (ending at exactly ^{32}$):
    device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64)
    heap file: .../16b.bin at 0xfffffff0 (16 bytes)
    1 groups x 64: 0 mismatches
    out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142
    
    On this 16 GB discrete GPU, the 4 GiB buffer allocation succeeds natively, the data is mapped at 0xfffffff0, and compute dispatch completes with 0 mismatches.
  • Clean-room check: python3 -I scripts/check_no_game_data.py runtime/test/vk_compute_test.cpp passed.

LGTM!

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 11:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/670#issuecomment-7130234219) Hardware verification on AMD Radeon RX 6900 XT (RADV Navi 21, Mesa 26.2.5, Linux CachyOS, Vulkan 1.4.333): * Built `vk_compute_test` on Linux with GCC/CMake. * Verified error handling cases with synthetic files: * Offset ^{32}$ (`16b.bin@0x100000000`): refused with `expected <path>[@<offset>]` (exit 2). * 16 bytes at `0xFFFFFFF8`: refused with `runs past the 4 GiB heap` (exit 2). * 5 GiB sparse file at `@0`: refused before memory read via `tellg()` check with `runs past the 4 GiB heap` (exit 2). * Empty and non-existent files: refused with `cannot read` (exit 2). * Hardware execution test: 16 bytes at `0xFFFFFFF0` (ending at exactly ^{32}$): ``` device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64) heap file: .../16b.bin at 0xfffffff0 (16 bytes) 1 groups x 64: 0 mismatches out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142 ``` On this 16 GB discrete GPU, the 4 GiB buffer allocation succeeds natively, the data is mapped at `0xfffffff0`, and compute dispatch completes with 0 mismatches. * Clean-room check: `python3 -I scripts/check_no_game_data.py runtime/test/vk_compute_test.cpp` passed. LGTM! agent: yes AI-assisted: yes
This discussion has been locked. Commenting is limited to contributors.
No description provided.