aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2025-05-09 16:18:49 -0700
committerGopher Robot <gobot@golang.org>2025-05-20 12:36:34 -0700
commitd596bc0e819aec2cf65a61d8b92f6bec8e0a7124 (patch)
tree14c158aaf6d5181ff698ff7d5f631961f129cfc4 /src/runtime
parentb7382cc1f012016c91036c49db0ea6db444b47d8 (diff)
downloadgo-d596bc0e819aec2cf65a61d8b92f6bec8e0a7124.tar.xz
runtime: disallow closing bubbled chans from outside bubble
A chan created within a synctest bubble may not be operated on from outside the bubble. We panicked on send and receive, but not close. Panic on close as well. For #67434 Change-Id: I98d39e0cf7baa1a679aca1fb325453d69c535308 Reviewed-on: https://go-review.googlesource.com/c/go/+/671960 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/chan.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/chan.go b/src/runtime/chan.go
index cb2737d096..63d8044b44 100644
--- a/src/runtime/chan.go
+++ b/src/runtime/chan.go
@@ -415,6 +415,9 @@ func closechan(c *hchan) {
if c == nil {
panic(plainError("close of nil channel"))
}
+ if c.synctest && getg().bubble == nil {
+ panic(plainError("close of synctest channel from outside bubble"))
+ }
lock(&c.lock)
if c.closed != 0 {