Mesa (staging/18.2): util: disable cache if we have no build-id and timestamp is zero

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 11 08:26:13 UTC 2018


Module: Mesa
Branch: staging/18.2
Commit: 4cd7db4b04ce0bc23730198c6ad61dd50d3cf8c8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cd7db4b04ce0bc23730198c6ad61dd50d3cf8c8

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Thu Sep 20 08:54:32 2018 +1000

util: disable cache if we have no build-id and timestamp is zero

Timestamp can be zero for example when Flatpak is used. In this
case just disable the cache rather then segfaulting when
incompatible cache items are loaded.

V2: actually return false when mtime is 0.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
(cherry picked from commit ea66bfda8801a0f5139c8e4655373117cdd7a1c0)

---

 src/amd/vulkan/radv_device.c | 4 ----
 src/util/disk_cache.h        | 9 +++++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 5cc5ddb9c0..4ce98098b5 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -61,10 +61,6 @@ radv_get_build_id(void *ptr, struct mesa_sha1 *ctx)
 	} else
 #endif
 	if (disk_cache_get_function_timestamp(ptr, &timestamp)) {
-		if (!timestamp) {
-			fprintf(stderr, "radv: The provided filesystem timestamp for the cache is bogus!\n");
-		}
-
 		_mesa_sha1_update(ctx, &timestamp, sizeof(timestamp));
 	} else
 		return false;
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 50bd9f41ac..c8685a53ed 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -26,6 +26,7 @@
 
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
+#include <stdio.h>
 #endif
 #include <assert.h>
 #include <stdint.h>
@@ -100,7 +101,15 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
    if (stat(info.dli_fname, &st)) {
       return false;
    }
+
+   if (!st.st_mtime) {
+      fprintf(stderr, "Mesa: The provided filesystem timestamp for the cache "
+              "is bogus! Disabling On-disk cache.\n");
+      return false;
+   }
+
    *timestamp = st.st_mtime;
+
    return true;
 }
 #endif




More information about the mesa-commit mailing list