diff --git a/src/cmd/internal/objabi/pkgspecial.go b/src/cmd/internal/objabi/pkgspecial.go index c34ede53fe0fb53f9c9384a055a06a4b1be9332c..b507d98dc7e94165b5bc2e0227f1952f3cb2324c 100644 --- a/src/cmd/internal/objabi/pkgspecial.go +++ b/src/cmd/internal/objabi/pkgspecial.go @@ -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", diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go index 45b1b5e9c7d42c0eeaae5ccc0e9010b096f0b770..839f3875be318bd25dc5da0f27c70e346a867857 100644 --- a/src/runtime/preempt.go +++ b/src/runtime/preempt.go @@ -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.