From 1f4d58ad5d6cdb03cd4f9d8062a711db9fe137bd Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 8 Aug 2013 13:46:30 -0400 Subject: 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 --- test/escape5.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/escape5.go') 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] +} -- cgit v1.2.1