Exception thrown stating "Access violation reading location 0x0000000000000018" when creating graphics pipeline

This error is prompted when creating the graphics pipeline which worked fine before. But after some changes to the code, this error prompts.
Capture

I debugged into the validation layers but I cant seem to find any invalid data. All the provided are valid and accessible. I even used the Application Verifier 10.0 to check for any memory corruptions but there weren’t any. After debugging into the validation layers, the CreateInfo structure contained the following data,

Is there any reason why this error might prompt? Shaders were updated heavily but then after this error, I reverted back to how it was before but this same error occurred. Validation layers were enabled but does not prompt any error.

Thank you!

What exactly do validation layers say about it?
Do you use git or some version control to pin down the code change that caused this?

Validation layers doesn’t say anything about this error.
Yes I do have a git repository but I didn’t use it to revert back to how it was because I updated the whole rendering library at once. What I did was I used the online “Vulkan Tutorial”’ shader and descriptor set creation code and pasted it in the same function scope as the pipeline creation call. I double checked every attribute in the createInfo structure and even checked its memory location and used the Application Validator to check if I’m passing any undefined memory pointer but the data I provided are valid without any memory corruption or sending a bad pointer.

If you’re getting an access violation, then it is most likely because some data pointer has been invalidated and not because of the validation layers, I’d suspect. Stuff like that can happen easily if you are using a std::vector and storing its .data() pointer in one of the structures. If you push elements into that vector after storing the data-pointer, chances are that the vector performs a reallocation internally (happens when e.g. its size grows from 1 to 2, from 2 to 4, from 4 to 8, or similar).

Make sure to run the Debug-build of your project and watch out for suspiciously looking memory addresses. Sometimes, my MSVC would show me memory addresses like 0xdddddddd when some data has become invalid. Please note that the original pointer address stays the same, but if you follow the data, you can get to odd looking addresses.

One more thought on the validation layers: If you think it is connected to them, have you tried to disable them completely?

Further ideas: Maybe not all of your data has been initialized? Maybe some struct members contain garbage data?

The memory address 0x00000018 could point to the problem. Are you, by chance, setting pStages = 0x00000018 which would correspond to assigning it VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO instead of letting pStages point to the actual memory that contains the data?
Valid would be something like follows:

std::vector<VkPipelineShaderStageCreateInfo> stages;
...pStages = stages.data(); // or pStages = &stages[0];

Invalid would be:

...pStages = (VkPipelineShaderStageCreateInfo*)stages[0];

or something similar.

The error turned out to be in the pipeline layout. The push constants were initialized in a dynamic array but soon after I initialized them in a static array, the error was gone.

The Validation layers didn’t catch it when creating the pipeline layout that made me think that the error was with the pipeline creation since the pipeline layout was created without any error.

Thank you!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.