]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: move zero-sized frame check from newproc to newproc1
authorAustin Clements <austin@google.com>
Fri, 9 Apr 2021 20:08:28 +0000 (16:08 -0400)
committerAustin Clements <austin@google.com>
Sun, 11 Apr 2021 20:07:18 +0000 (20:07 +0000)
If GOEXPERIMENT=regabidefer is enabled, newproc currently checks that
the call frame for new goroutines is empty. But there's one place in
the runtime (debugCallWrap), where we call newproc1, and it happens to
pass a non-empty frame. The current check didn't catch that. Move the
empty call frame check from newproc to newproc1 to catch this.

Updates #40724.

Change-Id: I9998faf1e07e7b7af88e06a8177127f998c40252
Reviewed-on: https://go-review.googlesource.com/c/go/+/309034
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/debug_test.go
src/runtime/proc.go

index c4c41f95f2dabe07ae7c600c3277a8233b4e7070..7f9e460303f51dd1035ffa05a30afa21da1b5746 100644 (file)
@@ -9,8 +9,12 @@
 // spends all of its time in the race runtime, which isn't a safe
 // point.
 
-//go:build amd64 && linux && !race
-// +build amd64,linux,!race
+// TODO(register args): We skip this under GOEXPERIMENT=regabidefer
+// because debugCallWrap passes a non-empty frame to newproc1,
+// triggering a panic.
+
+//go:build amd64 && linux && !race && !goexperiment.regabidefer
+// +build amd64,linux,!race,!goexperiment.regabidefer
 
 package runtime_test
 
index d545a143a036fc5daa7b691067775fe12a22848d..6c1c5dd91758cf7f810b0d9935368453827dd0a7 100644 (file)
@@ -4020,12 +4020,6 @@ func malg(stacksize int32) *g {
 //
 //go:nosplit
 func newproc(siz int32, fn *funcval) {
-       if goexperiment.RegabiDefer && siz != 0 {
-               // TODO: When we commit to GOEXPERIMENT=regabidefer,
-               // rewrite newproc's comment, since it will no longer
-               // have a funny stack layout or need to be nosplit.
-               throw("go with non-empty frame")
-       }
        argp := add(unsafe.Pointer(&fn), sys.PtrSize)
        gp := getg()
        pc := getcallerpc()
@@ -4051,6 +4045,14 @@ func newproc(siz int32, fn *funcval) {
 //
 //go:systemstack
 func newproc1(fn *funcval, argp unsafe.Pointer, narg int32, callergp *g, callerpc uintptr) *g {
+       if goexperiment.RegabiDefer && narg != 0 {
+               // TODO: When we commit to GOEXPERIMENT=regabidefer,
+               // rewrite the comments for newproc and newproc1.
+               // newproc will no longer have a funny stack layout or
+               // need to be nosplit.
+               throw("go with non-empty frame")
+       }
+
        _g_ := getg()
 
        if fn == nil {