From 4514207d25c098a320146a71bd093279fb5ee7fc Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 25 Apr 2023 13:17:26 -0700 Subject: [PATCH] vulkan: Handle alignment failure in the pipeline cache. On malloc failure, or more likely a passed in pDataSize < pipeline cache data size, we should return incomplete. Otherwise, vk_pipeline_cache_object_serialize will assertion fail about the start not being aligned. Closes: #8868 Fixes: 591da9877900 ("vulkan: Add a common VkPipelineCache implementation") Reviewed-by: Faith Ekstrand Reviewed-by: Samuel Pitoiset Part-of: (cherry picked from commit bc257928d7a431400dd8f83ff03590b7f5a1dda6) --- .pick_status.json | 2 +- src/vulkan/runtime/vk_pipeline_cache.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 4a9aac6e1bb..0e27879ddf9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -121,7 +121,7 @@ "description": "vulkan: Handle alignment failure in the pipeline cache.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "591da9877900c56434f9e23e0ad0058b118b0be8" }, diff --git a/src/vulkan/runtime/vk_pipeline_cache.c b/src/vulkan/runtime/vk_pipeline_cache.c index d5b9f347daa..27a246496e9 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.c +++ b/src/vulkan/runtime/vk_pipeline_cache.c @@ -760,7 +760,10 @@ vk_common_GetPipelineCacheData(VkDevice _device, intptr_t data_size_resv = blob_reserve_uint32(&blob); blob_write_bytes(&blob, object->key_data, object->key_size); - blob_align(&blob, VK_PIPELINE_CACHE_BLOB_ALIGN); + if (!blob_align(&blob, VK_PIPELINE_CACHE_BLOB_ALIGN)) { + result = VK_INCOMPLETE; + break; + } uint32_t data_size; if (!vk_pipeline_cache_object_serialize(cache, object,