From 6aad4213f8ef83f0995761da455e7ae9e864dc76 Mon Sep 17 00:00:00 2001 From: Simon HUET Date: Mon, 2 Nov 2026 11:31:25 +0100 Subject: [PATCH] fix(logger): prevent concurrent map read/write in ReduceFunctionName Acquire functionLock before checking functionCache in ReduceFunctionName to prevent data races when multiple goroutines log simultaneously. --- internal/logger/reduce.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/logger/reduce.go b/internal/logger/reduce.go index b35ebf3..75997ef 100644 --- a/internal/logger/reduce.go +++ b/internal/logger/reduce.go @@ -30,11 +30,12 @@ func reducePkgElements(elems []string) string { // Function used to reduce a Function name (from logging) func ReduceFunctionName(function string) string { + functionLock.Lock() + defer functionLock.Unlock() + if ret, ok := functionCache[function]; ok { return ret } - functionLock.Lock() - defer functionLock.Unlock() dir := filepath.Dir(function) base := filepath.Base(function)