]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: throw from the systemstack in wirep
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 22 Nov 2023 16:36:23 +0000 (16:36 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 22 Nov 2023 19:53:59 +0000 (19:53 +0000)
The exitsyscall path, since the introduction of the new execution
tracer, stores a just little bit more data in the exitsyscall stack
frame, causing a build failure from exceeding the nosplit limit with
'-N -l' set on all packages (like Delve does).

One of the paths through which this fails is "throw" from wirep, called
by a callee of exitsyscall. By switching to the systemstack on this
path, we can avoid hitting the nosplit limit, fixing the build. It's
also not totally unreasonable to switch to the systemstack for the
throws in this function, since the function has to be nosplit anyway. It
gives the throw path a bit more wiggle room to dump information than it
otherwise would have.

Fixes #64113.

Change-Id: I56e94e40614a202b8ac2fdc8b8b731493b74e5d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/544535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/proc.go

index 7a2283e3606e8cb04858ac8cc8123ee673b9edc7..63483358040e440e57e774a0aa09d20e1153d8c5 100644 (file)
@@ -5769,15 +5769,23 @@ func wirep(pp *p) {
        gp := getg()
 
        if gp.m.p != 0 {
-               throw("wirep: already in go")
+               // Call on the systemstack to avoid a nosplit overflow build failure
+               // on some platforms when built with -N -l. See #64113.
+               systemstack(func() {
+                       throw("wirep: already in go")
+               })
        }
        if pp.m != 0 || pp.status != _Pidle {
-               id := int64(0)
-               if pp.m != 0 {
-                       id = pp.m.ptr().id
-               }
-               print("wirep: p->m=", pp.m, "(", id, ") p->status=", pp.status, "\n")
-               throw("wirep: invalid p state")
+               // Call on the systemstack to avoid a nosplit overflow build failure
+               // on some platforms when built with -N -l. See #64113.
+               systemstack(func() {
+                       id := int64(0)
+                       if pp.m != 0 {
+                               id = pp.m.ptr().id
+                       }
+                       print("wirep: p->m=", pp.m, "(", id, ") p->status=", pp.status, "\n")
+                       throw("wirep: invalid p state")
+               })
        }
        gp.m.p.set(pp)
        pp.m.set(gp.m)