Skip to content

VK_EXT_debug_utils causes crash in Android Studio #68

@ts-numfum

Description

@ts-numfum

Using the latest Android Studio (Build #AI-251.26094.121.2512.13930704), I get a crash when I call vkSetDebugUtilsObjectNameEXT.
Virtual device: API 36, Android 16, x86_64 ABI.
As far as I know, the emulator uses gfxstream under the hood.

Source code of vkSetDebugUtilsObjectNameEXT:

VKAPI_ATTR VkResult VKAPI_CALL
vk_common_SetDebugUtilsObjectNameEXT(
   VkDevice _device,
   const VkDebugUtilsObjectNameInfoEXT *pNameInfo)
{
   VK_FROM_HANDLE(vk_device, device, _device);

#ifdef VK_USE_PLATFORM_ANDROID_KHR
   if (pNameInfo->objectType == VK_OBJECT_TYPE_SWAPCHAIN_KHR ||
       pNameInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) {
#else
   if (pNameInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) {
#endif
      mtx_lock(&device->swapchain_name_mtx);
      VkResult res = vk_common_set_object_name_locked(device, pNameInfo);
      mtx_unlock(&device->swapchain_name_mtx);
      return res;
   }

   struct vk_object_base *object =
      vk_object_base_from_u64_handle(pNameInfo->objectHandle,
                                     pNameInfo->objectType);

   assert(object->device != NULL || object->instance != NULL);
   VkAllocationCallbacks *alloc = object->device != NULL ?
      &object->device->alloc : &object->instance->alloc;
   if (object->object_name) {
      vk_free(alloc, object->object_name);
      object->object_name = NULL;
   }
   if (pNameInfo->pObjectName != NULL) {
      object->object_name = vk_strdup(alloc, pNameInfo->pObjectName,
                                      VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
      if (!object->object_name)
         return VK_ERROR_OUT_OF_HOST_MEMORY;
   }

   return VK_SUCCESS;
}

The crash occurs at vk_strdup, because of a nullpointer dereference.

There are no special steps needed to reproduce, it should be enough to enable VK_LAYER_KHRONOS_validation and VK_EXT_debug_utils, then call vkSetDebugUtilsObjectNameEXT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions