Skip to content

Commit 8b010a5

Browse files
committed
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
1 parent fe2abcb commit 8b010a5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

internal/quic/conn_async_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ func runAsync[T any](ts *testConn, f func(context.Context) (T, error)) *asyncOp[
101101
as := &ts.asyncTestState
102102
if as.notify == nil {
103103
as.notify = make(chan struct{})
104+
as.mu.Lock()
104105
as.blocked = make(map[*blockedAsync]struct{})
106+
as.mu.Unlock()
105107
}
106108
_, file, line, _ := runtime.Caller(1)
107109
ctx := context.WithValue(context.Background(), asyncContextKey{}, true)

0 commit comments

Comments
 (0)