From 941e6b7320daa0b08ffa66949eff994787ead210 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Fri, 13 Feb 2026 17:24:55 +0000 Subject: [PATCH] Fix filters_rwlock initialization race condition Add static initialization PTHREAD_RWLOCK_INITIALIZER to filters_rwlock in debug.cpp to prevent race condition where proxy_debug() is called before init_debug_struct() initializes the rwlock. This fixes Valgrind errors in filter_debug_entry() where threads were accessing an uninitialized rwlock. --- lib/debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/debug.cpp b/lib/debug.cpp index 35fc52866..cebcd0048 100644 --- a/lib/debug.cpp +++ b/lib/debug.cpp @@ -18,7 +18,7 @@ using std::unordered_map; __thread unsigned long long pretime=0; static pthread_mutex_t debug_mutex; -static pthread_rwlock_t filters_rwlock; +static pthread_rwlock_t filters_rwlock = PTHREAD_RWLOCK_INITIALIZER; static SQLite3DB * debugdb_disk = NULL; sqlite3_stmt *statement1=NULL; static stmt_unique_ptr statement1_unique {};