null pointer deref crash in wsi_common_x11.c
I was testing our Vulkan application when I hit a null pointer deref crash in wsi_common_x11.c
The Vulkan call at the time was vkGetPhysicalDeviceSurfaceSupportKHR(). My DISPLAY env var is pointed at a remote host. I'm using the Intel Vulkan driver, ToT Mesa code on Feb 14.
This patch fixes the issue for me:
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 6faecb6..11669eb 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -246,7 +246,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev,
ver_cookie = xcb_dri3_query_version(conn, 1, 2);
ver_reply = xcb_dri3_query_version_reply(conn, ver_cookie, NULL);
- has_dri3_v1_2 =
+ has_dri3_v1_2 = ver_reply != NULL &&
(ver_reply->major_version > 1 || ver_reply->minor_version >= 2);
free(ver_reply);
}
I think the root cause is something related to DRI3. When I run the app I see "vulkan: No DRI3 support detected - required for presentation. Note: you can probably enable DRI3 in your Xorg config". The target display is running Xorg w/ Nvidia driver.
I'm not 100% sure the above patch is right. Maybe another call to wsi_x11_check_for_dri3() is needed somewhere.
Note that the app always tries to set up Vulkan presentation/swapchain but falls back to our XPutImage() code when that fails. This has been working fine for quite a while. The crash when calling vkGetPhysicalDeviceSurfaceSupportKHR() is new. I recently updated the host which is hosting the app from Ubuntu 21.04 to 21.10 but I don't know if that has anything to do with it.