You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gui::update_buffers() can be called while explicit_update is false. In that mode the persistent vertex and index buffers are intentionally null until the first update, but the method dereferenced both pointers before allocating them.
This change short-circuits the two conditions when the corresponding buffer is null, allowing the existing allocation and upload path to initialize both buffers.
Reproduction
On macOS Apple Silicon (M2 Pro, macOS 26.6, Apple Clang 21, Vulkan SDK 1.4.341), an AddressSanitizer harness using the real GuiCpp::update_buffers() implementation and non-empty ImGui draw data reproduced a deterministic null dereference in the parent implementation:
SEGV on unknown address 0x000000000028
vk::Buffer::operator!()
vkb::Gui<(vkb::BindingType)1>::update_buffers()
Your fix might be correct. But it might as well just hide the actual error.
That is: does anybody know what that explicit_update flag is supposed to control?
The comment says "If true, update buffers every frame". But none of the two update_buffers functions in Gui seem to care about that flag.
In the Gui-constructor, it controls the initialization of the vertex_buffer and the index_buffer. But both are used unconditionally at several places.
Thanks for checking the lifecycle semantics. The explicit_update flag selects the persistent-buffer path: the constructor creates placeholder buffers, update_buffers() replaces/resizes and uploads them, and draw_impl() binds them. When the flag is false, draw_impl() instead allocates per-frame buffers through update_buffers(command_buffer). The two overloads therefore do not need to inspect the flag themselves; the caller/path selection does.\n\nThe null guards in this PR address the reported deferred-allocation case where a zero-sized ImGui frame leaves the persistent buffers null before a later draw. I agree the flag comment could be clearer, but I would prefer to keep that separate from this narrowly scoped fix unless you recommend combining them.
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
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.
Summary
Fixes #1508.
Gui::update_buffers()can be called whileexplicit_updateis false. In that mode the persistent vertex and index buffers are intentionally null until the first update, but the method dereferenced both pointers before allocating them.This change short-circuits the two conditions when the corresponding buffer is null, allowing the existing allocation and upload path to initialize both buffers.
Reproduction
On macOS Apple Silicon (M2 Pro, macOS 26.6, Apple Clang 21, Vulkan SDK 1.4.341), an AddressSanitizer harness using the real
GuiCpp::update_buffers()implementation and non-empty ImGui draw data reproduced a deterministic null dereference in the parent implementation:Validation
cmake --build build/repro --config Debug --target framework vulkan_samples -j4— passedctest --test-dir build/repro --output-on-failure— no tests found in this repository configurationpython3 scripts/copyright.py main --fix— passedgit diff --check— passed./scripts/clang_format.py main— could not run becauseclang-formatis not installedThe diff is limited to
framework/gui.h; no public API or dependency changes are included.