From: Austin Clements Date: Tue, 30 Mar 2021 18:45:00 +0000 (-0400) Subject: runtime: check that defer/go frames are empty X-Git-Tag: go1.17beta1~919 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e0ce0af6ef5232352852fa027fe51fa3fd01198e;p=gostls13.git runtime: check that defer/go frames are empty With GOEXPERIMENT=regabidefer, these frames should always be empty. Check that. For #40724. Change-Id: Id8e418a9e06b4f94543cb16b868a7e10e013c2d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/306009 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Than McIntosh Reviewed-by: Cherry Zhang --- diff --git a/src/runtime/panic.go b/src/runtime/panic.go index b5133fa5b4..c265a5af79 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -228,6 +228,11 @@ func deferproc(siz int32, fn *funcval) { // arguments of fn follow fn throw("defer on system stack") } + if experimentRegabiDefer && siz != 0 { + // TODO: Make deferproc just take a func(). + throw("defer with non-empty frame") + } + // the arguments of fn are in a perilous state. The stack map // for deferproc does not describe them. So we can't let garbage // collection or stack copying trigger until we've copied them out @@ -280,6 +285,9 @@ func deferprocStack(d *_defer) { // go code on the system stack can't defer throw("defer on system stack") } + if experimentRegabiDefer && d.siz != 0 { + throw("defer with non-empty frame") + } // siz and fn are already set. // The other fields are junk on entry to deferprocStack and // are initialized here. @@ -824,6 +832,9 @@ func runOpenDeferFrame(gp *g, d *_defer) bool { argWidth, fd = readvarintUnsafe(fd) closureOffset, fd = readvarintUnsafe(fd) nArgs, fd = readvarintUnsafe(fd) + if experimentRegabiDefer && argWidth != 0 { + throw("defer with non-empty frame") + } if deferBits&(1<