vulkan_present: guard make_capture_buffer against a null memory-properties pointer (RT-PRESENT-CAPTURE-NULLGUARD) #1223

Open
github-bot wants to merge 2 commits from github-bot/gh-1223 into main AGit
Owner

@⁠Miici0 on GitHub · 2026-11-24 20:34 UTC · original
Miici0:fix/xbox-present-capture-null-guard → main · +1 −0 · 1 files · 2 commits · open

Claimed in the coordination issue as: RT-PRESENT-CAPTURE-NULLGUARD (#14)

Depends on: none

Fixes: none

What and why

make_capture_buffer() in runtime/src/vulkan_present.h called vkGetPhysicalDeviceMemoryProperties_(physical_, ...) without checking the function pointer for null first, unlike prepare_compose() right above it, which does guard it. Found while investigating the intermittent xbox_present crash reported in #14 (finding at #14). This does not claim to fix that crash — the root cause there is still unconfirmed (it reproduces only through ctest, at roughly a 2% rate, and disappears under any validation layer or debugger, so it couldn't be caught live after over 100 attempts). This just closes a real null-pointer-call gap found along the way: if the extension function were ever unavailable, this call would crash immediately and unconditionally instead of failing the capture-buffer setup cleanly, as its sibling function already does.

Tested

ctest --test-dir runtime/build -C RelWithDebInfo -R "^xbox_present$": passes (2.99s). Full portable test suite otherwise unaffected (single-line, behavior-preserving guard; the function pointer is non-null in every environment observed, so this only changes behavior in the previously-unguarded null case).

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974, Vulkan SDK 1.4.363.1.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • N/A: no new translator rule.
**@⁠Miici0** on GitHub · 2026-11-24 20:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1223) `Miici0:fix/xbox-present-capture-null-guard` → `main` · +1 −0 · 1 files · 2 commits · open Claimed in the coordination issue as: RT-PRESENT-CAPTURE-NULLGUARD (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Depends on: none Fixes: none ### What and why `make_capture_buffer()` in `runtime/src/vulkan_present.h` called `vkGetPhysicalDeviceMemoryProperties_(physical_, ...)` without checking the function pointer for null first, unlike `prepare_compose()` right above it, which does guard it. Found while investigating the intermittent `xbox_present` crash reported in #14 (finding at https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). This does **not** claim to fix that crash — the root cause there is still unconfirmed (it reproduces only through `ctest`, at roughly a 2% rate, and disappears under any validation layer or debugger, so it couldn't be caught live after over 100 attempts). This just closes a real null-pointer-call gap found along the way: if the extension function were ever unavailable, this call would crash immediately and unconditionally instead of failing the capture-buffer setup cleanly, as its sibling function already does. ### Tested `ctest --test-dir runtime/build -C RelWithDebInfo -R "^xbox_present$"`: passes (2.99s). Full portable test suite otherwise unaffected (single-line, behavior-preserving guard; the function pointer is non-null in every environment observed, so this only changes behavior in the previously-unguarded null case). GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974, Vulkan SDK 1.4.363.1. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [ ] N/A: no new translator rule.
make_capture_buffer() called vkGetPhysicalDeviceMemoryProperties_ on the
presenter's physical device without checking the function pointer for
null first, unlike prepare_compose() right above it which does. Found
while investigating the intermittent xbox_present crash (#14, finding at
issuecomment-7143642803); this does not claim to fix that crash, it
closes a real null-pointer-call gap found during the investigation.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:43:29 +00:00
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 21:48 UTC · original

Read the diff at f849034a8 (not built or run by me). The guard sits after vkCreateBuffer, so on its path make_capture_buffer returns false with capture_buffer_ set and no memory bound. Nothing on that path releases it: the other failures in this function call release_capture() first.

That matters because finish_image tests capture_ && capture_buffer_ before copying into it. enable_capture clears capture_ when recreate fails, but a later recreation (a resize, say) with capture already on does not, and would leave an unbound buffer behind.

Moving the check to the top of the function, before vkCreateBuffer (and after release_capture()), avoids it. prepare_compose also checks before it creates anything.

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

**@⁠Snooozs** on GitHub · 2026-11-24 21:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1223#issuecomment-7145423120) Read the diff at `f849034a8` (not built or run by me). The guard sits after `vkCreateBuffer`, so on its path `make_capture_buffer` returns false with `capture_buffer_` set and no memory bound. Nothing on that path releases it: the other failures in this function call `release_capture()` first. That matters because `finish_image` tests `capture_ && capture_buffer_` before copying into it. `enable_capture` clears `capture_` when `recreate` fails, but a later recreation (a resize, say) with capture already on does not, and would leave an unbound buffer behind. Moving the check to the top of the function, before `vkCreateBuffer` (and after `release_capture()`), avoids it. `prepare_compose` also checks before it creates anything. AI-assisted (Claude Code, Claude Opus 5.5).
Snooozs's review on #1223: the null guard ran after vkCreateBuffer, so on that
failure path capture_buffer_ was left set with no bound memory, and nothing
called release_capture() the way the other failure paths in the function do.
Move the guard to the top, right after release_capture(), before anything is
created.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1223/head:github-bot/gh-1223'
git switch 'github-bot/gh-1223'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1223'
git switch 'github-bot/gh-1223'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1223'
git switch 'github-bot/gh-1223'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1223'
git switch 'main'
git merge --squash 'github-bot/gh-1223'
git switch 'main'
git merge --ff-only 'github-bot/gh-1223'
git switch 'main'
git merge 'github-bot/gh-1223'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.