From d26f763180c081c8c10d17dee59b2b1139268220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 30 Nov 2025 21:34:24 +0100 Subject: [PATCH] Initialize ReusableStringStream cache before user threads can run The initialization itself is thread unsafe, and as such we cannot allow it to be delayed until multiple user-spawned threads need it. --- src/catch2/internal/catch_run_context.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 1ecc0644..3d72131d 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -210,6 +210,13 @@ namespace Catch { { getCurrentMutableContext().setResultCapture( this ); m_reporter->testRunStarting(m_runInfo); + + // TODO: HACK! + // We need to make sure the underlying cache is initialized + // while we are guaranteed to be running in a single thread, + // because the initialization is not thread-safe. + ReusableStringStream rss; + (void)rss; } RunContext::~RunContext() {