how to debug vkCreateInstance exception/crash

I’m running into several issues, the main problem is that I get an unhandled exception inside vkCreateInstance. This happens if I am running a debug binary or if I have any validation layers active. If I test with a release binary it will create, but then I cant get past creating a surface although that does not except. Anyways one problem at a time.

All of the information I have read in terms of debugging vulkan involve the validation layers, however all that appears to be dependent on having a working VkInstance to begin with.

I have tried for days to figure this out, but am completely stuck on it. My system can run the SDK cube demo just fine, and the output of vulkaninfo indicates I have what I need to develop. I have also followed the vulkan tutorial and that works as a standalone solution/project, however that same code in the context of my target codebase has this problem.

context: windows application, x64, using Vulkan lunarG SDK Version: 1.0.65, built with VisStudio2015 using VC tools 140 (c++14) on a win 7 x64 OS

Here is an example of how I’m creating the instance, although this is just a pared down setup, it is one of a hundred attempts at getting it to work:


VkInstance instance = nullptr;

VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.pApplicationInfo = nullptr;
createInfo.enabledExtensionCount = 0;
createInfo.enabledLayerCount = 0;
createInfo.pNext = nullptr;

VkResult result = vkCreateInstance(&createInfo, nullptr, &instance);


any advice is appreciated.

this is the exception type I get:

Access violation reading location 0xFFFFFFFFFFFFFFFF

Do LunarG samples even work for you to begin with? If so, compare them to your code, there has got to be something that you do wrong.

yes, they do, and yes I have, including against many other examples/samples. Yet the code/example I gave crashes when run in the environment I need to work in…

Is your project of the same bitness as LunarG samples? I.e., I believe AMD does not support 32-bit Vulkan (it’s not supposed to crush, though).

From experience, some buggy drivers do not like createInfo.pApplicationInfo = nullptr;. Try to provide real struct.

Which dll file crashes?

Try one of the VS templates from VulkanSDK\1.0.65.1\Templates. In VS right click on Solution and select Retarget, otherwise should just work OOTB.

Yes it is 64 bit project target.

Yes I have provided a real appinfo struct many times in many different variations, as well as extensions/layers, the example I gave was deliberately pared down, more complex/complete creation setups have the exact same problem.

I have tried the samples themselves and they work in their standalone projects. By retarget you mean to add one of them into my project and see if it still works? Alright I’ll try that.

I have tried the samples themselves and they work in their standalone projects. By retarget you mean to add one of them into my project and see if it still works? Alright I’ll try that.

No, there are templates for Visual Studio projects in the path I provided. Just try those. They have properly set paths to the SDK and have only instance creation code.
By Retarget I mean to change the Windows SDK and platform-tools (which may point to versions you do not have installed, and the compiler should complain trying to build). There is a Retarget context menu in VS2017 for convenience. Otherwise it is in Project Properties->General.

PS: do you have all SPs installed for your VS2015?

can you clarify what you mean by “SPs installed for your VS2015?”?

Almost certainly “Service Packs”. That is, have you updated to the latest version of VS2015?

As for service packs, my VS says its fully updated, it is at version 14.0.25431.01 update 3

As for platform target it is at win kit 8.1 which is what I want and what my app targets.

I tried the templates again and yes they work in and of themselves. Looking at the simplest example I do not see a difference in the code with my case. So it is likely the environment or something else.

I got the pdb loading so that I can step into the function, and subsequently I see that the values of the VkInstanceCreateInfo struct and the VkApplicationInfo struct (if I pass it) become garbled when the vkCreateInstance function reads them, so for example in my code I set enabledExtensionCount to 0 before passing it, yet on the other side it was showing having a value of 3435973836 in the debugger. So that explains the crash but I have no idea why this happens.

Finally figured it out. I noticed that the sizeof the vk struct types in my project differed from the sdk template project’s, and I found the culprit: the compiler option /Zp4 was being set (forces struct alignment to packing to 4 byte boundaries) so I removed that so that it uses the default of 8, and now vkCreateInstance returns success!