diff options
| author | Keith Randall <khr@golang.org> | 2014-04-07 17:40:00 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2014-04-07 17:40:00 -0700 |
| commit | fc6753c7cd788cbd50cb80e18764541934141e63 (patch) | |
| tree | 8db3462b4512a51a79257584a180c4e2d57414c8 /src/pkg/runtime/stack_test.go | |
| parent | af923df89ee65428b0a8cba7323e9397926ea0e6 (diff) | |
| download | go-fc6753c7cd788cbd50cb80e18764541934141e63.tar.xz | |
runtime: make sure associated defers are copyable before trying to copy a stack.
Defers generated from cgo lie to us about their argument layout.
Mark those defers as not copyable.
CL 83820043 contains an additional test for this code and should be
checked in (and enabled) after this change is in.
Fixes bug 7695.
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/84740043
Diffstat (limited to 'src/pkg/runtime/stack_test.go')
| -rw-r--r-- | src/pkg/runtime/stack_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/pkg/runtime/stack_test.go b/src/pkg/runtime/stack_test.go index e131ed94ed..f3c531eb93 100644 --- a/src/pkg/runtime/stack_test.go +++ b/src/pkg/runtime/stack_test.go @@ -257,3 +257,20 @@ func growStackWithCallback(cb func()) { f(i) } } + +// TestDeferPtrs tests the adjustment of Defer's argument pointers (p aka &y) +// during a stack copy. +func set(p *int, x int) { + *p = x +} +func TestDeferPtrs(t *testing.T) { + var y int + + defer func() { + if y != 42 { + t.Errorf("defer's stack references were not adjusted appropriately") + } + }() + defer set(&y, 42) + growStack() +} |
