KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

State tracker: read nullptr

Open
#11,637 1 comment 0 reactions 0 assignees View on GitHub
BestPractices Bug
Dominant language
C++
Stars
1k
Forks
504
Avg merge
11h 35m
Merged PRs (30d)
224

Description

**Environment:**
- OS: Windows 11 25H2
- GPU and driver version: NVIDIA GeForce RTX 3050 6GB Laptop GPU. Driver: 0x91474000. API: 1.4.312
- SDK or header version if building from repo: tested on 1.3.290.0 and 1.4.341.1
- Options enabled (synchronization, best practices, etc.): best practices

**Describe the Issue**

A segmentation fault occurs inside the Vulkan Validation Layers when the Best Practices validation preset is enabled. The crash happens even without AddressSanitizer; ASAN was only used afterward to help identify the crash location.

The application runs correctly without validation layers enabled - no crashes, device loss, or rendering issues. All other validation presets also work normally. The problem appears only when Best Practices is enabled.

ASAN indicates a null pointer read in:

* `vvl::Framebuffer::LinkChildNodes()`
* called from `vvl::DeviceState::PostCallRecordCreateFramebuffer()`

The crash occurs during `vkCreateFramebuffer` while recreating the swapchain.

The issue appears to be order-dependent. It reproduces intermittently when swapchain recreation is performed in the following order:

1. Stop using / detach old swapchain-dependent resources
2. Destroy the swapchain
3. Create the new swapchain and its dependent resources
4. Destroy the old swapchain-dependent resources (framebuffers, image views, etc.)

Reordering the destruction so that all swapchain-dependent objects are destroyed before destroying the swapchain prevents the crash.

While this order may violate object lifetime expectations, the validation layers should ideally report a validation error rather than crash.

**Expected behavior**

The validation layers should not crash, even if the application provides an invalid object lifetime order. Instead, they should emit a validation error or otherwise handle the situation gracefully.

**Valid Usage ID**
No validation messages are emitted prior to the crash. The process terminates with a segmentation fault inside the validation layers.

**Additional context**

ASAN Stacktrace

```sh
=================================================================
==50352==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x7ffbde04f6b6 bp 0x00cbac9ea889 sp 0x00cbac9ea7e0 T0)
==50352==The signal is caused by a READ memory access.
==50352==Hint: address points to the zero page.
#0 0x7ffbde04f6b5 in vvl::Framebuffer::LinkChildNodes(void) C:\SDKBuild\build-X64-1.4.341.1\Vulkan-ValidationLayers\layers\state_tracker\render_pass_state.cpp:430
#1 0x7ffbde07f32b in vvl::DeviceState::PostCallRecordCreateFramebuffer(struct VkDevice_T *, struct VkFramebufferCreateInfo const *, struct VkAllocationCallbacks const *, struct VkFramebuffer_T **, struct RecordObject const &) C:\SDKBuild\build-X64-1.4.341.1\Vulkan-ValidationLayers\layers\state_tracker\state_tracker.cpp:3498
#2 0x7ffbddd1090e in vulkan_layer_chassis::CreateFramebuffer(struct VkDevice_T *, struct VkFramebufferCreateInfo const *, struct VkAllocationCallbacks const *, struct VkFramebuffer_T **) C:\SDKBuild\build-X64-1.4.341.1\Vulkan-ValidationLayers\layers\vulkan\generated\chassis.cpp:4533
#3 0x7ffcc659886c (C:\WINDOWS\SYSTEM32\vulkan-1.dll+0x18006886c)
#4 0x7ffc3ea012be in vk::Result vk::Device::createFramebuffer(vk::FramebufferCreateInfo const*, vk::AllocationCallbacks const*, vk::Framebuffer*, vk::DispatchLoaderDynamic const&) const C:/VulkanSDK/1.3.290.0/Include/vulkan/vulkan_funcs.hpp:4141:33
#5 0x7ffc3ea012be in agrb::create_fb_handles(agrb::framebuffer*, agrb::device&) C:/Users/wusik/Documents/code/app3d/modules/agrb/src/framebuffer.cpp:165:35
#6 0x7ff69f7249d7 in graphics::CompositionFramebuffer::recreate_attachments(vk::Extent2D, agrb::device&) C:/Users/wusik/Documents/code/app3d/src/graphics/render/postprocess/fb_composition.cpp:33:14
#7 0x7ff69f75d811 in graphics::render::Renderer::recreate_swapchain(vk::Extent2D, agrb::device&) C:/Users/wusik/Documents/code/app3d/src/graphics/render/renderer.cpp:37:29
#8 0x7ff69f760247 in graphics::render::Renderer::bind_events(acul::events::dispatcher&)::$_0::operator()(awin::PosEvent&) const C:/Users/wusik/Documents/code/app3d/src/graphics/render/renderer.cpp:18:17
#9 0x7ff69f75e4aa in acul::unique_function::vtable_t const* acul::unique_function::vt_inplace()::'lambda'(void*, awin::PosEvent&)::operator()(void*, awin::PosEvent&) const C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/functional/unique_function.hpp:44:77
#10 0x7ff69f75e1d9 in acul::unique_function::vtable_t const* acul::unique_function::vt_inplace()::'lambda'(void*, awin::PosEvent&)::__invoke(void*, awin::PosEvent&) C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/functional/unique_function.hpp:42:38
#11 0x7ff69f6518ab in acul::unique_function::operator()(awin::PosEvent&) const C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/functional/unique_function.hpp:160:20
#12 0x7ff69f6517d2 in acul::events::listener::invoke(awin::PosEvent&) C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/event.hpp:63:33
#13 0x7ff69f5fc6c6 in void acul::events::thunk(void*, acul::events::event&) C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/event.hpp:84:47
#14 0x7ffcbcec685c in void acul::events::event_group::dispatch(awin::PosEvent&) C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/event.hpp:158:36
#15 0x7ffcbcebd7e2 in void acul::events::dispatch_event_group&>(acul::events::event_group*, awin::event_id::$_0&&, awin::Window*&, acul::point2D&) C:/Users/wusik/Documents/code/app3d/modules/acul/include/acul/event.hpp:214:22
#16 0x7ffcbcebbd75 in awin::platform::wnd_proc(HWND__*, unsigned int, unsigned long long, long long) C:/Users/wusik/Documents/code/app3d/modules/awin/src/__os_win32_window.cpp:470:25
#17 0x7ffd16ae6b45 (C:\WINDOWS\System32\USER32.dll+0x180016b45)
#18 0x7ffd16ae660b (C:\WINDOWS\System32\USER32.dll+0x18001660b)
#19 0x7ffc66292199 in auik::imgui_wnd_proc(HWND__*, unsigned int, unsigned long long, long long) C:/Users/wusik/Documents/code/app3d/modules/auik/src/integration/window.cpp:214:16
#20 0x7ffd16ae6b45 (C:\WINDOWS\System32\USER32.dll+0x180016b45)
#21 0x7ffd16ae5e52 (C:\WINDOWS\System32\USER32.dll+0x180015e52)
#22 0x7ffd16ae2e4e (C:\WINDOWS\System32\USER32.dll+0x180012e4e)
#23 0x7ffd16ae2ad3 (C:\WINDOWS\System32\USER32.dll+0x180012ad3)
#24 0x7ffd11a6a753 (C:\WINDOWS\system32\uxtheme.dll+0x18000a753)
#25 0x7ffd11a6a6a0 (C:\WINDOWS\system32\uxtheme.dll+0x18000a6a0)
#26 0x7ffd16ae42f9 (C:\WINDOWS\System32\USER32.dll+0x1800142f9)
#27 0x7ffcbcebc920 in awin::platform::wnd_proc(HWND__*, unsigned int, unsigned long long, long long) C:/Users/wusik/Documents/code/app3d/modules/awin/src/__os_win32_window.cpp:544:20
#28 0x7ffd16ae6b45 (C:\WINDOWS\System32\USER32.dll+0x180016b45)
#29 0x7ffd16ae660b (C:\WINDOWS\System32\USER32.dll+0x18001660b)
#30 0x7ffc66292199 in auik::imgui_wnd_proc(HWND__*, unsigned int, unsigned long long, long long) C:/Users/wusik/Documents/code/app3d/modules/auik/src/integration/window.cpp:214:16
#31 0x7ffd16ae6b45 (C:\WINDOWS\System32\USER32.dll+0x180016b45)
#32 0x7ffd16ae63cb (C:\WINDOWS\System32\USER32.dll+0x1800163cb)
#33 0x7ffd16b20652 (C:\WINDOWS\System32\USER32.dll+0x180050652)
#34 0x7ffd17a05a73 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x180165a73)
#35 0x7ffd14ab2c83 (C:\WINDOWS\System32\win32u.dll+0x180002c83)
#36 0x7ffcbcec04c2 in awin::Window::position(acul::point2D) C:/Users/wusik/Documents/code/app3d/modules/awin/src/__os_win32_window.cpp:769:9
#37 0x7ff69f5f2143 in init_window_events(acul::shared_ptr> const&) C:/Users/wusik/Documents/code/app3d/src/app/app.cpp:84:46
#38 0x7ff69f5f39a3 in App::prepare() C:/Users/wusik/Documents/code/app3d/src/app/app.cpp:182:5
#39 0x7ff69f811685 in main C:/Users/wusik/Documents/code/app3d/src/main.cpp:65:13
#40 0x7ff69f5f10fd in __tmainCRTStartup D:/W/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:260:11
#41 0x7ff69f5f13e5 in .l_start D:/W/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:129:9
#42 0x7ffd1639e8d6 (C:\WINDOWS\System32\KERNEL32.DLL+0x18002e8d6)
#43 0x7ffd1792c40b (C:\WINDOWS\SYSTEM32\ntdll.dll+0x18008c40b)

==50352==Register values:
rax = 7ffbde6ceb20 rbx = 131aa75fb570 rcx = 0 rdx = 131aa77b0d10
rdi = 131aa77b0d10 rsi = 131aa75fb5a0 rbp = cbac9ea889 rsp = cbac9ea7e0
r8 = 131aa75fb5a0 r9 = 1 r10 = 0 r11 = 29a8f13e2d0
r12 = 30 r13 = 131aa771c080 r14 = cbac9ea880 r15 = 131aa7680d00
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation C:\SDKBuild\build-X64-1.4.341.1\Vulkan-ValidationLayers\layers\state_tracker\render_pass_state.cpp:430 in vvl::Framebuffer::LinkChildNodes(void)
==50352==ABORTING

```

Contributor guide

Open the contributing guide

Research direction

Start in layers/state_tracker/render_pass_state.cpp at Framebuffer::LinkChildNodes(), then trace the call from DeviceState::PostCallRecordCreateFramebuffer() in layers/state_tracker/state_tracker.cpp. Reproduce the swapchain recreation and destruction order described in the issue with Best Practices enabled. Done means the invalid lifetime sequence no longer causes a null-pointer crash and is handled gracefully, ideally with a validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.