diff options
| author | Damien Neil <dneil@google.com> | 2024-11-21 17:32:22 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-11-22 16:21:27 +0000 |
| commit | a8eddaf758c15404acbfe61af0739b6d099f2067 (patch) | |
| tree | ed4f927f4fd004287314429dd49ceb980a8cbff1 /src/runtime | |
| parent | 00709919d09904b17cfe3bfeb35521cbd3fb04f8 (diff) | |
| download | go-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.go | 27 |
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() +} |
