Skip to content

Segmentation fault in SampleLayer_CreateDevice #4

Description

@hysw

I'm creating this issue since I can't find the source for https://renderdoc.org/vulkan-layer-guide.html and make a pull request.

In layer's CreateDevice function

92  VK_LAYER_EXPORT VkResult VKAPI_CALL SampleLayer_CreateDevice(...)
97  {
      ...
118   PFN_vkCreateDevice createFunc = (PFN_vkCreateDevice)gipa(VK_NULL_HANDLE, "vkCreateDevice");
119
120   VkResult ret = createFunc(physicalDevice, pCreateInfo, pAllocator, pDevice);

Here pfnNextGetInstanceProcAddr is called with VK_NULL_HANDLE and "vkCreateDevice" which the return is undefined according to the Vulkan spec. Most implementations happens to return a valid vkCreateDevice pointer. However renderdoc layer returns nullptr in this case and we got a segfault.

A correct implementation should get the instance from physical device and pass that to pfnNextGetInstanceProcAddr.

$ ENABLE_SAMPLE_LAYER=1 ENABLE_VULKAN_RENDERDOC_CAPTURE=1 vkcube

...

Thread 1 "vkcube" received signal SIGSEGV, Segmentation fault.

#0  ?? ()
#1  SampleLayer_CreateDevice (physicalDevice=0x5555555a67e0, 
    pCreateInfo=0x7fffffffc1c0, pAllocator=0x0, pDevice=0x7fffffffc178) at sample_layer.cpp:120
120       VkResult ret = createFunc(physicalDevice, pCreateInfo, pAllocator, pDevice);
...

(gdb) print createFunc
$1 = (PFN_vkCreateDevice) 0x0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions