Skip to content

vulkan: don't keep a buffer-chain node whose buffer was not mapped - #19747

Merged
LibretroAdmin merged 2 commits into
libretro:masterfrom
milnet01:pr/vulkan-buffer-node-unmapped
Oct 8, 2026
Merged

LibretroAdmin merged 2 commits into
libretro:masterfrom
milnet01:pr/vulkan-buffer-node-unmapped

Conversation

@milnet01

@milnet01 milnet01 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

vulkan_create_buffer returns a buffer with mapped == NULL when creation, memory allocation or vkMapMemory fails. vulkan_buffer_chain_alloc_node kept such a node, and vulkan_buffer_chain_suballoc then handed out mapped + offset as the range's data, which callers memcpy into.

The node allocator now destroys the buffer, frees the node and returns NULL. vulkan_buffer_chain_alloc already returns false in that case, and its callers check it.

Testing (Linux x86_64): full build; the file compiles without warnings. Not run: this path is reached only when an allocation fails, and nothing here can force that.

Found by a static-analysis pass over the tree.

🤖 Generated with Claude Code

milnet01 and others added 2 commits October 8, 2026 17:00
vulkan_create_buffer returns a buffer with mapped == NULL when
creation, allocation or vkMapMemory fails. The buffer chain kept such
a node, and suballoc then handed out NULL plus an offset as the
range's data. Drop the node instead; vulkan_buffer_chain_alloc already
returns false when no node can be made.

Tests: none run; no harness links vulkan.c. RetroArch builds with the change and the file compiles without warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The HDR pass writes its uniforms through the buffer's mapping, which is
NULL when vkMapMemory failed at init; the pass is skipped then, as it is
when no descriptor set can be had.

check-vulkan-mapfail runs the Vulkan lanes through the fake memory
layer with the first map of a 64 KiB buffer refused on each device -
the size of a buffer-chain block - and every lane must still pass. A
chain that kept the unmapped node wrote through NULL; the Vulkan
validation workflow runs it after the XRGB8888 pass.
@LibretroAdmin
LibretroAdmin merged commit 21b1255 into libretro:master Oct 8, 2026
108 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants