Tests/triangle-vulkan.c crash on resize

The triangle-vulkan crashes on window resize due to freeing & then not creating the command buffer. When it later goes to use said command buffer, because the pointer wasn’t nulled out it assumes it is still valid, uses it and segfaults.

The fix is a one liner

2178:     if (demo->setup_cmd) {
2179:         vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->setup_cmd);
2180:         demo->setup_cmd = NULL;
2181:     }

Great find, thanks! This looks like a bug which should be filed at https://github.com/glfw/glfw/issues, with a PR request if you want to see your github username in the commit list. I you don’t have a github account or don’t have time for this I can do it for you.

From the example I think the preferred syntax for NULL is VK_NULL_HANDLE, even if some of the tests assume that’s the same as NULL.

demo->setup_cmd  =  VK_NULL_HANDLE;

I was going to make an PR/issue, but couldn’t figure out how at first. Do I need to first fork the project?

After looking at the issues link and making a new one, it seems I’m not the first to have come across the issue. But also its worth noting that the example is rather old & needs to be replaced anyhow.

and yes, VK_NULL_HANDLE is preferred.

It seems I’ve been beaten to the punch!

Glad to see the fix get in so quickly, and I appreciate getting credit, even if its just one line.
I might take a deeper dive into the code later on and try to fix up some of the validation layer warnings that have appeared. Though, that’s an idle thought about how it needs TLC.

Helping with the examples, particularly the Vulkan ones, it likely going to be appreciated. I don’t know quite what plans @elmindreda and the rest of the core team have for GLFW but Vulkan will likely become a stronger focus as time goes on, so we may need better tests and examples.

There’s a contribution guide up on https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md if you’re interested.