diff options
author | Russ Cox <rsc@golang.org> | 2013-08-08 13:46:30 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2013-08-08 13:46:30 -0400 |
commit | 1f4d58ad5d6cdb03cd4f9d8062a711db9fe137bd (patch) | |
tree | 091c2f9d429430a8027d73f0d65f43ff5c225ac0 /test/escape5.go | |
parent | bdbd5418f4c2dc87fa18e6b39e4ead21c6d87bbe (diff) | |
download | go-git-1f4d58ad5d6cdb03cd4f9d8062a711db9fe137bd.tar.gz |
cmd/gc: move large stack variables to heap
Individual variables bigger than 10 MB are now
moved to the heap, as if they had escaped on
their own.
This avoids ridiculous stacks for programs that
do things like
x := [1<<30]byte{}
... use x ...
If 10 MB is too small, we can raise the limit.
Fixes #6077.
R=ken2
CC=golang-dev
https://golang.org/cl/12650045
Diffstat (limited to 'test/escape5.go')
-rw-r--r-- | test/escape5.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/escape5.go b/test/escape5.go index 6b327fe9e3..c9646872d5 100644 --- a/test/escape5.go +++ b/test/escape5.go @@ -142,3 +142,10 @@ func f9() { var j T1 // ERROR "moved to heap: j" 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" + _ = x[0] + y[0] +} |