aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2024-11-21 17:32:22 -0800
committerGopher Robot <gobot@golang.org>2024-11-22 16:21:27 +0000
commita8eddaf758c15404acbfe61af0739b6d099f2067 (patch)
treeed4f927f4fd004287314429dd49ceb980a8cbff1 /src/runtime
parent00709919d09904b17cfe3bfeb35521cbd3fb04f8 (diff)
downloadgo-a8eddaf758c15404acbfe61af0739b6d099f2067.tar.xz
runtime, internal/synctest, syscall/js: keep bubble membership in syscalls
Propagate synctest bubble membership through syscall/js.Func functions. Avoids panics from cross-bubble channel operations in js syscalls. Fixes #70512 Change-Id: Idbd9f95da8bc4f055a635dfac041359f848dad1a Reviewed-on: https://go-review.googlesource.com/c/go/+/631055 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/synctest.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/runtime/synctest.go b/src/runtime/synctest.go
index 0fd5e7873e..09748d5c1c 100644
--- a/src/runtime/synctest.go
+++ b/src/runtime/synctest.go
@@ -270,3 +270,30 @@ func synctestwait_c(gp *g, _ unsafe.Pointer) bool {
unlock(&gp.syncGroup.mu)
return true
}
+
+//go:linkname synctest_acquire internal/synctest.acquire
+func synctest_acquire() any {
+ if sg := getg().syncGroup; sg != nil {
+ sg.incActive()
+ return sg
+ }
+ return nil
+}
+
+//go:linkname synctest_release internal/synctest.release
+func synctest_release(sg any) {
+ sg.(*synctestGroup).decActive()
+}
+
+//go:linkname synctest_inBubble internal/synctest.inBubble
+func synctest_inBubble(sg any, f func()) {
+ gp := getg()
+ if gp.syncGroup != nil {
+ panic("goroutine is already bubbled")
+ }
+ gp.syncGroup = sg.(*synctestGroup)
+ defer func() {
+ gp.syncGroup = nil
+ }()
+ f()
+}