Bugfix device memory report bind path hardening - #34
Merged
olehkuznetsov merged 15 commits intoSep 17, 2026
Merged
olehkuznetsov merged 15 commits into
olehkuznetsov merged 15 commits into
Conversation
Guard the vkBind*Memory entry points against absent dispatch table
entries instead of calling through unconditionally, returning
VK_ERROR_EXTENSION_NOT_PRESENT when the underlying function was not
loaded.
Proactively query vkGet{Buffer,Image}MemoryRequirements at bind time for
resources whose size has not been recorded yet, so suballocations are
sized correctly even when the application never triggered a size
recording path.
Fall back to the owning allocation's total size in BindResourceMemory
when a resource has no recorded size, and track resources bound without
a prior create call, so these bindings are no longer silently dropped.
Add test_DeviceMemoryReport_dispatch, a test binary that links the layer
sources directly and drives its vk* entry points against a stub dispatch
table, so the interception logic can be exercised without a Vulkan ICD. The
Vulkan loader is deliberately not linked: the layer defines the entry points
itself, and the existing test_DeviceMemoryReport_layer binary loads the layer
as a shared module, so the layer's DeviceMemoryReport singleton is a
different instance from the one it can inspect.
Covers the bind path hardening:
- vkBindBufferMemory / vkBindImageMemory and the four vkBind*Memory2[KHR]
entry points query vkGet{Buffer,Image}MemoryRequirements for resources
whose size has not been recorded yet, so those bindings are sized instead
of dropped.
- Sizes that are already known are neither re-queried nor overwritten.
- All six bind entry points return VK_ERROR_EXTENSION_NOT_PRESENT when the
driver below the layer does not provide the command, rather than calling
through a null dispatch table entry.
Against the previous implementation the size tests report 0 bytes and the
missing dispatch entry test crashes with SIGSEGV.
olehkuznetsov
requested changes
Sep 15, 2026
…mory Revert dummy resource synthesis and allocation size fallback, returning early when a resource was not previously created or has zero recorded size.
…ries Assert dispatch table entry presence for core 1.0 vkBind*Memory commands instead of returning VK_ERROR_EXTENSION_NOT_PRESENT. Avoid calling legacy vkGetImageMemoryRequirements for multi-planar disjoint image plane bindings.
…cution Add DeviceMemoryReport::Reset() and invoke it in SetUp() and TearDown() of DeviceMemoryReportDispatchTests so tests are hermetic under shuffling and repetition. Update dispatch tests to match the hardened entry points.
…report-bind-path-hardening
olehkuznetsov
left a comment
There was a problem hiding this comment.
Nice hardening pass — the proactive vkGet*MemoryRequirements lookup closes a real gap where resources bound without a prior vkCreate* interception were never sized, and moving the core 1.0 bind paths to assertions is the right direction.
Two things I'd like resolved before merge, both in device_memory_report_handwritten_functions.h:
- The
vkBind*Memory2{,KHR}entry points returnVK_ERROR_EXTENSION_NOT_PRESENT, which is out of contract for those commands — and there's a new test pinning that behaviour. - The disjoint-image guard added in
c41b3bc3eonly inspects the firstpNextelement, so it doesn't reliably do what the commit title says.
The rest are small consistency nits. Neither blocker is a crash or memory-safety issue.
olehkuznetsov
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.