Mesa (staging/22.1): vulkan/wsi: fix crash with debug names on swapchain

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 23 16:19:36 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 940cb75c9350ca1d5c150d0efa9050f3a35246c3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=940cb75c9350ca1d5c150d0efa9050f3a35246c3

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Mon Jun 20 13:00:38 2022 +0000

vulkan/wsi: fix crash with debug names on swapchain

If you set a name of on a swapchain object, because the base object
struct has not been initialized with a VkDevice,
vk_object_base_finish() will segfault when trying to free the object
name.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Fixes: cb1e0db23e3f ("vulkan/wsi: Make wsi_swapchain inherit from vk_object_base")
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17165>
(cherry picked from commit efc398c722ae47afd01ed1abd83abb208bba9692)

---

 .pick_status.json           |  2 +-
 src/vulkan/wsi/wsi_common.c | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index c635feda384..c858c93cb3b 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1057,7 +1057,7 @@
         "description": "vulkan/wsi: fix crash with debug names on swapchain",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "cb1e0db23e3fa17562bb276b125aeab0b85582cb"
     },
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index ed3feac4822..562efdd529c 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -222,24 +222,25 @@ wsi_device_setup_syncobj_fd(struct wsi_device *wsi_device,
 VkResult
 wsi_swapchain_init(const struct wsi_device *wsi,
                    struct wsi_swapchain *chain,
-                   VkDevice device,
+                   VkDevice _device,
                    const VkSwapchainCreateInfoKHR *pCreateInfo,
                    const VkAllocationCallbacks *pAllocator,
                    bool use_buffer_blit)
 {
+   VK_FROM_HANDLE(vk_device, device, _device);
    VkResult result;
 
    memset(chain, 0, sizeof(*chain));
 
-   vk_object_base_init(NULL, &chain->base, VK_OBJECT_TYPE_SWAPCHAIN_KHR);
+   vk_object_base_init(device, &chain->base, VK_OBJECT_TYPE_SWAPCHAIN_KHR);
 
    chain->wsi = wsi;
-   chain->device = device;
+   chain->device = _device;
    chain->alloc = *pAllocator;
    chain->use_buffer_blit = use_buffer_blit;
    chain->buffer_blit_queue = VK_NULL_HANDLE;
    if (use_buffer_blit && wsi->get_buffer_blit_queue)
-      chain->buffer_blit_queue = wsi->get_buffer_blit_queue(device);
+      chain->buffer_blit_queue = wsi->get_buffer_blit_queue(_device);
 
    int cmd_pools_count = chain->buffer_blit_queue != VK_NULL_HANDLE ? 1 : wsi->queue_family_count;
 
@@ -262,7 +263,7 @@ wsi_swapchain_init(const struct wsi_device *wsi,
          .flags = 0,
          .queueFamilyIndex = queue_family_index,
       };
-      result = wsi->CreateCommandPool(device, &cmd_pool_info, &chain->alloc,
+      result = wsi->CreateCommandPool(_device, &cmd_pool_info, &chain->alloc,
                                       &chain->cmd_pools[i]);
       if (result != VK_SUCCESS)
          goto fail;



More information about the mesa-commit mailing list