Segfault when calling vkGetDeviceQueue() with optimization flag

I was going through the vulkan-tutorial (but in C and with SDL2) when I started getting a crash in the createLogicalDevice() portion of the code.

It only crashes in Release mode and the only real difference is the optimization flags (with curtain values):
-Og: runs
-O1: runs
-O2: crash
-O3: crash

It crashes on the first call to vkGetDeviceQueue(). VK_CHECK just checks that a function returns VK_SUCCESS, if not then I log it and crash the program-- from my logs, it is successful.

...
VK_CHECK(vkCreateDevice(pApp->vkPhysicalDevice, &createInfo, NULL, &pApp->vkDevice));

/* vvv Crashes here vvv */
vkGetDeviceQueue(pApp->vkDevice, indices.graphicsFamily, 0, &pApp->vkGraphicsQueue);   
vkGetDeviceQueue(pApp->vkDevice, indices.presentFamily, 0, &pApp->vkPresentQueue);
...

Here’s the gdb session for release mode:
pApp->vkDevice seems to be valid before I call vkGetDeviceQueue().

...
Thread 1 hit Breakpoint 2, _AppCreateLogicalDevice (pApp=0x2ae165069e0)
    at D:\dev\VulkanTutorial\src\HyperMoon\src\app\app.c:833
833         VK_CHECK(vkCreateDevice(pApp->vkPhysicalDevice, &createInfo, NULL, &pApp->vkDevice));
(gdb)  p pApp->vkDevice
$1 = (VkDevice) 0x0
(gdb) next
[New Thread 7336.0x287c]
835         vkGetDeviceQueue(pApp->vkDevice, indices.graphicsFamily, 0, &pApp->vkGraphicsQueue);
(gdb) p pApp->vkDevice
$2 = (VkDevice) 0x2ae1960b800
(gdb) next

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffe70a480c8 in vulkan-1!vkResetFences ()
   from C:\windows\SYSTEM32\vulkan-1.dll
(gdb)

Setup info:
OS: Windows 10 (64-bit)
CPU: Intel(R) Celeron(R) N4020 CPU
GPU: Intel(R) UHD Graphics 600
Env: Mingw
Compiler: gcc.exe (tdm64-1) 10.3.0
Vulkan: 1.3.231.1

Value of createInfo (VkDeviceCreateInfo) at the time of crash:

createInfo
{
    sType: VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO
    pNext: 0x0
    flags: 0
    queueCreateInfoCount: 1
    pQueueCreateInfos: 0x90325ff1d0
    enabledLayerCount: 0
    ppEnabledLayerNames: 0x0
    enabledExtensionCount: 1
    ppEnabledExtensionNames: 0x7ff6bbfd6770 <deviceExtensions>
    pEnabledFeatures: 0x90325ff1d0
}

Um, maybe you could enable some debugging layers.

Run it through the Validation Layers. That can be simply done via env variable or newly through a GUI configurator too (Also make sure they actually work and successfully report errors)

Getting to vkGetDeviceQueue is simple short and sweet, so I think I am gonna require you to provide a complete verifiable minimal example, as is proper.

Accompanying it with VK_LAYER_LUNARG_api_dump log might help to spot bugs faster. Assuming there is any bug on your part that is.

I figured it out. In the tutorial, they use the STL set and vector to create a unique vector of VkDeviceQueueCreateInfos. Since I’m using C, I rolled my own vector types… long story short, in Release mode with optimization flags, this:

queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;

was being set to some other structure type in my vector type. So I switched to using a pointer and that worked.

But thank you for your recommendations!