]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.24] runtime: explicitly disable async preempt for internal/runtime
authorAndy Pan <i@andypan.me>
Wed, 5 Mar 2025 08:14:42 +0000 (16:14 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 26 Mar 2025 16:38:08 +0000 (09:38 -0700)
Fixes #72115
For #71591
Relevant CL 560155

Change-Id: Iebc497d56b36d50c13a6dd88e7bca4578a03cf63
Reviewed-on: https://go-review.googlesource.com/c/go/+/654916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
(cherry picked from commit 92a63bdfee9f8347df70293e5733661ae31ae285)
Reviewed-on: https://go-review.googlesource.com/c/go/+/660857
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

src/cmd/internal/objabi/pkgspecial.go
src/runtime/preempt.go

index 9828e12281444f3c30c9f19a0ba77825a8c84678..871c28f58829ab4e7505b15b84ff4612e6d2b30a 100644 (file)
@@ -43,6 +43,9 @@ type PkgSpecial struct {
 }
 
 var runtimePkgs = []string{
+       // TODO(panjf2000): consider syncing the list inside the
+       //      isAsyncSafePoint in preempt.go based on this list?
+
        "runtime",
 
        "internal/runtime/atomic",
index 45b1b5e9c7d42c0eeaae5ccc0e9010b096f0b770..839f3875be318bd25dc5da0f27c70e346a867857 100644 (file)
@@ -419,14 +419,21 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) {
        name := u.srcFunc(uf).name()
        if stringslite.HasPrefix(name, "runtime.") ||
                stringslite.HasPrefix(name, "runtime/internal/") ||
+               stringslite.HasPrefix(name, "internal/runtime/") ||
                stringslite.HasPrefix(name, "reflect.") {
                // For now we never async preempt the runtime or
                // anything closely tied to the runtime. Known issues
                // include: various points in the scheduler ("don't
                // preempt between here and here"), much of the defer
                // implementation (untyped info on stack), bulk write
-               // barriers (write barrier check),
-               // reflect.{makeFuncStub,methodValueCall}.
+               // barriers (write barrier check), atomic functions in
+               // internal/runtime/atomic, reflect.{makeFuncStub,methodValueCall}.
+               //
+               // Note that this is a subset of the runtimePkgs in pkgspecial.go
+               // and these checks are theoretically redundant because the compiler
+               // marks "all points" in runtime functions as unsafe for async preemption.
+               // But for some reason, we can't eliminate these checks until https://go.dev/issue/72031
+               // is resolved.
                //
                // TODO(austin): We should improve this, or opt things
                // in incrementally.