| // Copyright 2020 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| var x [N]int // stack-allocated memory |
| // This defer checks to see if x is uncorrupted. |
| fmt.Printf("p[%d]=0x%x\n", j, p[j]) |
| panic("corrupted stack variable") |
| // This defer starts a new goroutine, which will (hopefully) |
| // overwrite x on the garbage stack. |
| // This defer causes a stack copy. |
| // The old stack is now garbage. |
| // Make the return statement unreachable. |
| // That makes the stack map at the deferreturn call empty. |
| // In particular, the argument to the first defer is not |
| // marked as a pointer, so it doesn't get adjusted |
| // during the stack copy. |