[go] crypto/tls: avoid data race when canceling a QUICConn's Context

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Feb 5, 2026, 8:06:00 PM (2 days ago) Feb 5
to Damien Neil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Roland Shoemaker, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
crypto/tls: avoid data race when canceling a QUICConn's Context

Methods on QUICConn are synchronous:
The connection state is expected to change only in reaction
to a user calling a QUICConn method, and the state change
should finish completely before the method returns.

The connection context provided to QUICConn.Start violates
this model, because canceling the context causes an
asynchronous state change.

Prior to CL 719040, this caused no problems because canceling
the context did not cause any user-visible state changes.
In particular, canceling the context did not cause any new
events to be immediately returned by QUICConn.NextEvent.

CL 719040 introduced a new error event. Now, canceling a
QUICConn's context causes a new connection event to be
generated.

Receiving this event causes a data race visible to the
race detector, but the core problem is not the data race
itself: It's that an asynchronous event (canceling the
connection context) causes an change to the connection
events.

Fix this race by reworking the handling of QUICConn
context cancellation a bit. We no longer react to
cancellation while control of the connection lies
with the user. We only process cancellation as
part of a user call, such as QUICConn.Close
or QUICConn.HandleData.

Fixes #77274
Change-Id: If2e0f73618c4852114e0931b6bd0cb0b6a6a6964
Auto-Submit: Damien Neil <dn...@google.com>
Reviewed-by: Roland Shoemaker <rol...@golang.org>
Files:
  • M src/crypto/tls/conn.go
  • M src/crypto/tls/quic.go
  • M src/crypto/tls/quic_test.go
Change size: S
Delta: 3 files changed, 29 insertions(+), 13 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Roland Shoemaker
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: If2e0f73618c4852114e0931b6bd0cb0b6a6a6964
Gerrit-Change-Number: 742561
Gerrit-PatchSet: 2
Gerrit-Owner: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Roland Shoemaker <rol...@golang.org>
open
diffy
satisfied_requirement

Gopher Robot (Gerrit)

unread,
Feb 6, 2026, 2:13:35 PM (2 days ago) Feb 6
to Damien Neil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Michael Pratt, Roland Shoemaker, Go LUCI, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
[release-branch.go1.26] crypto/tls: avoid data race when canceling a QUICConn's Context
(cherry picked from commit d4febb45179fa99ee1d5783bcb693ed7ba14115c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/742761
TryBot-Bypass: Dmitri Shuralyov <dmit...@golang.org>
Auto-Submit: Michael Pratt <mpr...@google.com>
Reviewed-by: Michael Pratt <mpr...@google.com>
Files:
  • M src/crypto/tls/conn.go
  • M src/crypto/tls/quic.go
  • M src/crypto/tls/quic_test.go
Change size: S
Delta: 3 files changed, 29 insertions(+), 13 deletions(-)
Branch: refs/heads/release-branch.go1.26
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Roland Shoemaker, +2 by Michael Pratt
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI, TryBot-Bypass+1 by Dmitri Shuralyov
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: release-branch.go1.26
Gerrit-Change-Id: If2e0f73618c4852114e0931b6bd0cb0b6a6a6964
Gerrit-Change-Number: 742761
Gerrit-PatchSet: 2
Gerrit-Owner: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Roland Shoemaker <rol...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages