From e1ec361d0b39748d321472b2be7298211e05a3b6 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 9 Dec 2022 22:55:27 -0500 Subject: [PATCH] http2: fix race in TestCanonicalHeaderCacheGrowth As Damien found in the 2nd patch set of CL 455736 and CL 455735, disableGoroutineTracking is racy (but only called by benchmarks that don't care); set the serverConn.serveG in the test instead. Fixes golang/go#57218. Change-Id: I5e39be3c7fbac93260a26951491863b06b39d672 Reviewed-on: https://go-review.googlesource.com/c/net/+/456523 Run-TryBot: Dmitri Shuralyov Reviewed-by: Damien Neil TryBot-Result: Gopher Robot Auto-Submit: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov --- http2/server_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http2/server_test.go b/http2/server_test.go index a1e086c193..815efe1c9a 100644 --- a/http2/server_test.go +++ b/http2/server_test.go @@ -4547,10 +4547,11 @@ func TestServerInitialFlowControlWindow(t *testing.T) { // TestCanonicalHeaderCacheGrowth verifies that the canonical header cache // size is capped to a reasonable level. func TestCanonicalHeaderCacheGrowth(t *testing.T) { - defer disableGoroutineTracking()() for _, size := range []int{1, (1 << 20) - 10} { base := strings.Repeat("X", size) - sc := &serverConn{} + sc := &serverConn{ + serveG: newGoroutineLock(), + } const count = 1000 for i := 0; i < count; i++ { h := fmt.Sprintf("%v-%v", base, i)