glfw/glfw

[VULKAN] Segfault on glfwTerminate if window resized in its lifetime

JohnyTheCarrot opened this issue · 1 comments

OS: Windows 11 64-bit
Release: 3.3.8 (also happens on 3.4)
Call stack:

glfwDestroyWindow(GLFWwindow *) window.c:430 (memset line)
terminate init.c:69
glfwTerminate init.c:354
  • The segfault happens when the program is being shut down and glfwTerminate is called, not while running.
  • The segfault ONLY happens if the window is resized in its lifetime

My own research

It would seem that during glfwTerminate, _glfw.windowListHead contains a valid window which is then destroyed. When I step over this the window does indeed disappear.

This _glfw.windowListHead however contains a next window pointer whose value is 0x0000000000000001, which causes the segfault when it is its turn to be destroyed.

When a resize is detected, I recreate the vulkan swap chain, so I checked the detection of the resize, where I request the new framebuffer's dimensions, and when stepping into the glfwGetFramebufferSize call, I noticed the window already has a next pointer that is 0x0000000000000001. This call happens before the swap chain recreation.

Reproducible build

Unfortunately as I have no idea what actually causes this issue I was not able to make a minimal reproducible build, so all I have to provide is the entire thing.

https://github.com/JohnyTheCarrot/GP2_RayTracer/tree/0234cd042492bf2cfc5fca0e8bb1364ab403e29a

Useful images

clion64_rYSY9gXLN4
FPzagPTBl2
xs2kfPjRGj

I can't replicate this issue with either my own Vulkan code nor the tirangle-vulkan GLFW test on Windows 11 64bit with GLFW from latest Github, and have not had this issue with earlier versions either.

First I would check the GLFW triangle-vulkan test. This can most easily be built from source with cmake. The default options should create Visual Studio build files with the tests and examples.

If these work fine I would then use the Vulkan debug layers to check your application code. This is most easily done with the Vulkan Configurator using the Validation layer with Standard Preset. It might be a good idea to update your Vulkan SDK first.