Segmentation fault on program termination with RAII Vulkan headers
@ozanyasindogan is already working on this.
Since Aug 8, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- computer-graphics, documentation
Research direction
Start with the tutorial's RAII Vulkan example and inspect the HelloTriangleApplication cleanup function and destruction order around glfwDestroyWindow and glfwTerminate. Compare the open pull request linked to this issue before making changes. Done means the tutorial no longer segfaults during termination while retaining the RAII object lifetime behavior.
Written by the indexing model from the issue text.
Description
Hi!
I followed the new tutorial that uses RAII Vulkan headers. Everything works fine, but there is one problem: before the program terminates, when the HelloTriangleApplication instance is destroyed, all the vk::raii objects are destroyed after the glfwDestroyWindow and glfwTerminate calls, which creates a segmentation fault. To avoid this, I added this code to the cleanup function:
void cleanup() {
inFlightFences.clear();
renderSemaphores.clear();
presentSemaphores.clear();
commandBuffers.clear();
commandPool = nullptr;
pipeline = nullptr;
pipelineLayout = nullptr;
imageViews.clear();
images.clear();
swapChain = nullptr;
surface = nullptr;
queue = nullptr;
device = nullptr;
physicalDevice = nullptr;
debugMessenger = nullptr;
instance = nullptr;
glfwDestroyWindow(window);
window = nullptr;
glfwTerminate();
}
This allows all destructors of Vulkan objects to be called before the GLFW window is destroyed.
I find this solution inconvenient because it completely kills the benefits of RAII.
Am I missing something in the tutorial?
- Dominant language
- C++
- Stars
- 424
- Forks
- 127
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from KhronosGroup/Vulkan-Tutorial
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
KhronosGroup/Vulkan-Tutorial#519 · 1 assignee ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
KhronosGroup/Vulkan-Tutorial#511 · 1 assignee ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
KhronosGroup/Vulkan-Tutorial#508 · 1 assignee ·
-
Difficulty 1/5 Under an hour Newbie friendliness 74/100
KhronosGroup/Vulkan-Tutorial#499 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
KhronosGroup/Vulkan-Tutorial#498 ·
All issues in KhronosGroup/Vulkan-Tutorial
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mlcommons/mobile_app_open#1182 ·
-
Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/winget-cli#6547 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·