Skip to content

Commit d76873b

Browse files
authored
fix: avoid deadlock in TestStringPoolRaceCondition (#1395)
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
1 parent b2c1dcd commit d76873b

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

pkg/report/strings_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,10 @@ func TestStringPoolRaceCondition(t *testing.T) {
223223
pool := NewStringPool()
224224

225225
var wg sync.WaitGroup
226-
wg.Add(numGoroutines * 3)
227226

228227
// Concurrent interning of identical strings
229228
for range numGoroutines {
230229
wg.Go(func() {
231-
defer wg.Done()
232230
for range numOps {
233231
pool.Intern("shared")
234232
}
@@ -238,17 +236,16 @@ func TestStringPoolRaceCondition(t *testing.T) {
238236
// Concurrent interning of unique strings
239237
for i := range numGoroutines {
240238
wg.Go(func() {
241-
defer wg.Done()
242239
for j := range numOps {
243240
pool.Intern(fmt.Sprintf("unique-%d-%d", i, j))
244241
}
245242
})
246243
}
247244

248-
// Concurrent clear operations
249-
for range numGoroutines {
245+
// Use a small number of goroutines to exercise the race detector without triggering
246+
// resize contention in xsync.Map.
247+
for range 10 {
250248
wg.Go(func() {
251-
defer wg.Done()
252249
for range numOps {
253250
pool.clear()
254251
}

0 commit comments

Comments
 (0)