From 8b010a5243b670aca8d2277a3c989d1b6a198a08 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 29 Aug 2023 09:25:04 -0700 Subject: [PATCH] quic: fix race condition in runAsync test helper asyncTestState.wakeAsync runs on the conn's goroutine and accesses as.blocked, so we need to hold as.mu while initializing as.blocked in runAsync. For golang/go#58547 Change-Id: Idb5921895cee89dfceec2b2439c43f2e380b64ce Reviewed-on: https://go-review.googlesource.com/c/net/+/524095 LUCI-TryBot-Result: Go LUCI Reviewed-by: Jonathan Amsterdam --- internal/quic/conn_async_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/quic/conn_async_test.go b/internal/quic/conn_async_test.go index 0da3ddb452..5b419c4e54 100644 --- a/internal/quic/conn_async_test.go +++ b/internal/quic/conn_async_test.go @@ -101,7 +101,9 @@ func runAsync[T any](ts *testConn, f func(context.Context) (T, error)) *asyncOp[ as := &ts.asyncTestState if as.notify == nil { as.notify = make(chan struct{}) + as.mu.Lock() as.blocked = make(map[*blockedAsync]struct{}) + as.mu.Unlock() } _, file, line, _ := runtime.Caller(1) ctx := context.WithValue(context.Background(), asyncContextKey{}, true)