Fix fossilize_db bug.

This commit is contained in:
Dave Airlie 2021-10-12 09:41:19 +10:00
parent fd6e1b261b
commit 0e8fed6388
2 changed files with 51 additions and 1 deletions

View file

@ -0,0 +1,46 @@
From 8de60a1654a875d0b55512a1508f541f706f9b97 Mon Sep 17 00:00:00 2001
From: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Date: Sat, 4 Sep 2021 03:32:21 +0200
Subject: [PATCH] util/fossilize_db: Don't corrupt keys during entry read.
We change the hash that is still used to set entry->key.
Fixes: d2d642cc014 "util/fossilize_db: Only allocate entries after full read."
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12725>
---
src/util/fossilize_db.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/util/fossilize_db.c b/src/util/fossilize_db.c
index e1709a1ff64..26024101b83 100644
--- a/src/util/fossilize_db.c
+++ b/src/util/fossilize_db.c
@@ -156,18 +156,18 @@ update_foz_index(struct foz_db *foz_db, FILE *db_idx, unsigned file_idx)
offset += header->payload_size;
parsed_offset = offset;
- /* Truncate the entry's hash string to a 64bit hash for use with a
- * 64bit hash table for looking up file offsets.
- */
- hash_str[16] = '\0';
- uint64_t key = strtoull(hash_str, NULL, 16);
-
struct foz_db_entry *entry = ralloc(foz_db->mem_ctx,
struct foz_db_entry);
entry->header = *header;
entry->file_idx = file_idx;
_mesa_sha1_hex_to_sha1(entry->key, hash_str);
+ /* Truncate the entry's hash string to a 64bit hash for use with a
+ * 64bit hash table for looking up file offsets.
+ */
+ hash_str[16] = '\0';
+ uint64_t key = strtoull(hash_str, NULL, 16);
+
entry->offset = cache_offset;
_mesa_hash_table_u64_insert(foz_db->index_db, key, entry);
--
2.31.1

View file

@ -58,7 +58,7 @@ Name: mesa
Summary: Mesa graphics libraries
%global ver 21.1.8
Version: %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)}
Release: 2%{?dist}
Release: 3%{?dist}
License: MIT
URL: http://www.mesa3d.org
@ -69,6 +69,7 @@ Source0: https://mesa.freedesktop.org/archive/%{name}-%{ver}.tar.xz
Source1: Mesa-MLAA-License-Clarification-Email.txt
Patch1: 0001-device_select-close-dri3-fd-after-using-it.patch
Patch2: 0001-util-fossilize_db-Don-t-corrupt-keys-during-entry-re.patch
BuildRequires: meson >= 0.45
BuildRequires: gcc
BuildRequires: gcc-c++
@ -603,6 +604,9 @@ popd
%files vulkan-devel
%changelog
* Tue Oct 12 2021 Dave Airlie <airlied@redhat.com> - 21.1.8-3
- Fix fossilize_db bug.
* Wed Oct 06 2021 Dave Airlie <airlied@redhat.com> - 21.1.8-2
- add fix for leaking fd in device select