]> Cypherpunks repositories - gostls13.git/commit
[dev.typeparams] runtime: don't keep stack uintptr across potential stack move
authorAustin Clements <austin@google.com>
Mon, 26 Jul 2021 14:54:57 +0000 (10:54 -0400)
committerAustin Clements <austin@google.com>
Tue, 27 Jul 2021 15:44:31 +0000 (15:44 +0000)
commitcb14e673ec62f09f1216c3d40b03a460785a931e
tree12f52c93e4911c5da101827eadc16e18a57e4192
parent37d2219960340614f4d7e67c2e620013594e131a
[dev.typeparams] runtime: don't keep stack uintptr across potential stack move

Currently, deferproc stores the caller SP as a uintptr in a local
variable across a call to newdefer, but newdefer could grow the stack
and invalidate this saved SP, causing deferproc to store a stale SP in
the defer record. This would lead to us later failing to match that
defer to its calling frame, and we wouldn't run the defer at the right
time (or possibly at all).

It turns out this isn't crashing horribly right now only because the
compiler happens to only materialize the result of getcallersp when
this variable is used, *after* the call to newdefer. But this is
clearly on thin ice, so this CL moves the getcallersp() to the place
where we actually need the result.

Change-Id: Iae8ab226e03e4482f16acfb965885f0bd83a13b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/337649
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/panic.go