1
0
mirror of https://github.com/golang/go synced 2024-09-29 09:24:28 -06:00

runtime: throw from the systemstack in wirep

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>
This commit is contained in:
Michael Anthony Knyszek 2023-11-22 16:36:23 +00:00 committed by Michael Knyszek
parent 186c473424
commit 37aed23f51

View 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)