[Mesa-dev] [PATCH] disk_cache: assert if a cache entries keys don't match mesa

Eduardo Lima Mitev elima at igalia.com
Fri Aug 25 06:34:29 UTC 2017


On 08/25/2017 06:04 AM, Timothy Arceri wrote:
> In ef42423e7be9 I enable the check for release builds however we
> still want to assert in debug builds to alert to collisions or
> just general bugs with the key building/compare code. Otherwise
> it will just fail silently effectively disabling the cache.
> ---

Looks good.

Nitpicking, I would perhaps change "to alert to collisions" in the
commit message by "to alert of collisions". It reads a bit off.

Reviewed-by: Eduardo Lima Mitev <elima at igalia.com>

>  src/util/disk_cache.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index 36c1e8e72c..b789a454eb 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -1078,22 +1078,24 @@ disk_cache_get(struct disk_cache *cache, const cache_key key, size_t *size)
>        goto fail;
>  
>     if (sb.st_size < ck_size)
>        goto fail;
>  
>     ret = read_all(fd, file_header, ck_size);
>     if (ret == -1)
>        goto fail;
>  
>     /* Check for extremely unlikely hash collisions */
> -   if (memcmp(cache->driver_keys_blob, file_header, ck_size) != 0)
> +   if (memcmp(cache->driver_keys_blob, file_header, ck_size) != 0) {
> +      assert(!"Mesa cache keys mismatch!");
>        goto fail;
> +   }
>  
>     size_t cache_item_md_size = sizeof(uint32_t);
>     uint32_t md_type;
>     ret = read_all(fd, &md_type, cache_item_md_size);
>     if (ret == -1)
>        goto fail;
>  
>     if (md_type == CACHE_ITEM_TYPE_GLSL) {
>        uint32_t num_keys;
>        cache_item_md_size += sizeof(uint32_t);
> 



More information about the mesa-dev mailing list