From f259a7b0c31781cac306c40eb9240ea011310800 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 4 Jan 2023 10:22:57 -0500 Subject: [PATCH] lavapipe: use PACKAGE_VERSION for cache uuid in release builds MESA_GIT_SHA1 is defined as "", which results in invalid access fixes #7673 Fixes: b38879f8c5f ("vallium: initial import of the vulkan frontend") Reviewed-by: Dave Airlie Part-of: (cherry picked from commit c17d0cc488320a2cc5c67e7db7c07e7869cc0b36) --- .pick_status.json | 2 +- src/gallium/frontends/lavapipe/lvp_device.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a76b14f4c74..884fb77cdc3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1165,7 +1165,7 @@ "description": "lavapipe: use PACKAGE_VERSION for cache uuid in release builds", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b38879f8c5f57b7f1802e433e33181bdf5e72aef" }, diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index ed2cf868620..e88e2b17a3f 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1076,8 +1076,13 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceFeatures2( void lvp_device_get_cache_uuid(void *uuid) { - memset(uuid, 0, VK_UUID_SIZE); - snprintf(uuid, VK_UUID_SIZE, "val-%s", &MESA_GIT_SHA1[4]); + memset(uuid, 'a', VK_UUID_SIZE); + if (MESA_GIT_SHA1[0]) + /* debug build */ + memcpy(uuid, &MESA_GIT_SHA1[4], strlen(MESA_GIT_SHA1) - 4); + else + /* release build */ + memcpy(uuid, PACKAGE_VERSION, strlen(PACKAGE_VERSION)); } VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,