From b6e0ec4faa64de44628480ece3a12961cf0452e4 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 30 Sep 2025 17:16:28 -0400 Subject: [PATCH] Fix segfault when running `unique()` on different threads Signed-off-by: Juan Cruz Viotti --- src/core/json/json_value.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/json/json_value.cc b/src/core/json/json_value.cc index 76cd67d18..c191e3f8a 100644 --- a/src/core/json/json_value.cc +++ b/src/core/json/json_value.cc @@ -741,8 +741,10 @@ JSON::defines_any(std::initializer_list keys) const -> bool { return true; } - static std::vector cache; - cache.reserve(size); + // If we re-use the vector across threads, then we will segfault + thread_local std::vector cache; + cache.clear(); + cache.resize(size); for (std::size_t index = 0; index < size; index++) { cache[index] = items[index].fast_hash();