Mesa (main): radv: Add more checking of cache sizes.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 16 01:22:41 UTC 2021


Module: Mesa
Branch: main
Commit: 6e3266709a9a4b85a414c0400603e66859a2aaa3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e3266709a9a4b85a414c0400603e66859a2aaa3

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Sun Nov 14 23:59:41 2021 +0100

radv: Add more checking of cache sizes.

Hopefully prevents things.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13789>

---

 src/amd/vulkan/radv_pipeline_cache.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index 0e8e515f1b1..87fe7f5c7d8 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -369,8 +369,12 @@ radv_create_shaders_from_pipeline_cache(
          *stack_sizes = malloc(entry->num_stack_sizes * sizeof(**stack_sizes));
          memcpy(*stack_sizes, p, entry->num_stack_sizes * sizeof(**stack_sizes));
       }
+   } else {
+      assert(!entry->num_stack_sizes);
    }
 
+   p += entry->num_stack_sizes * sizeof(**stack_sizes);
+
    if (device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE && cache == device->mem_cache)
       vk_free(&cache->alloc, entry);
    else {
@@ -379,6 +383,7 @@ radv_create_shaders_from_pipeline_cache(
             p_atomic_inc(&entry->shaders[i]->ref_count);
    }
 
+   assert((uintptr_t)p <= (uintptr_t)entry + entry_size(entry));
    radv_pipeline_cache_unlock(cache);
    return true;
 }



More information about the mesa-commit mailing list