diff options
author | David Chase <drchase@google.com> | 2015-05-20 15:16:34 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2015-05-22 02:13:54 +0000 |
commit | e5060c7f7524bf32e07f62d2593aae8d280725e5 (patch) | |
tree | 7efca0287fca9550dd5f886d64fc164f99da241b /test/escape5.go | |
parent | b19ec6842d3d3bdc6d7b67fa065121a9d317cff7 (diff) | |
download | go-e5060c7f7524bf32e07f62d2593aae8d280725e5.tar.gz go-e5060c7f7524bf32e07f62d2593aae8d280725e5.zip |
cmd/internal/gc: move check for large-hence-heap-allocated types into escape analysis
Before this change, the check for too-large arrays (and other large
types) occurred after escape analysis. If the data moved off stack
and onto the heap contained any pointers, it would therefore escape,
but because the too-large check occurred after escape analysis this
would not be recorded and a stack pointer would leak to the heap
(see the modified escape_array.go for an example).
Some of these appear to remain, in calls to typecheck from within walk.
Also corrected a few comments in escape_array.go about "BAD"
analysis that is now done correctly.
Enhanced to move aditional EscNone-but-large-so-heap checks into esc.c.
Change-Id: I770c111baff28a9ed5f8beb601cf09dacc561b83
Reviewed-on: https://go-review.googlesource.com/10268
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'test/escape5.go')
-rw-r--r-- | test/escape5.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/test/escape5.go b/test/escape5.go index 1d411b32d4..6a138ea090 100644 --- a/test/escape5.go +++ b/test/escape5.go @@ -117,7 +117,6 @@ func leakrecursive2(p, q *int) (*int, *int) { // ERROR "leaking param: p" "leaki return p, q } - var global interface{} type T1 struct { @@ -141,12 +140,12 @@ func f8(p *T1) (k T2) { // ERROR "leaking param: p to result k" "leaking param: func f9() { var j T1 // ERROR "moved to heap: j" - f8(&j) // ERROR "&j escapes to heap" + f8(&j) // ERROR "&j escapes to heap" } func f10() { // These don't escape but are too big for the stack - var x [1<<30]byte // ERROR "moved to heap: x" - var y = make([]byte, 1<<30) // ERROR "does not escape" + var x [1 << 30]byte // ERROR "moved to heap: x" + var y = make([]byte, 1<<30) // ERROR "make\(\[\]byte, 1 << 30\) escapes to heap" _ = x[0] + y[0] } |