3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test stack splitting code.
8 // Try to tickle stack splitting bugs by doing
9 // go, defer, and closure calls at different stack depths.
15 func g(c
chan int, t T
) {
17 for i
:= 0; i
< len(t
); i
++ {
25 for i
:= 0; i
< len(t
); i
++ {
29 println("bad defer", s
)
35 // likely to make a new stack for f0,
36 // because the call to f1 puts 3000 bytes
41 func f1() [3000]byte {
42 // likely to make a new stack for f1,
43 // because 3000 bytes were used by f0
44 // and we need 3000 more for the call
45 // to f2. if the call to morestack in f1
46 // does not pass the frame size, the new
47 // stack (default size 5k) will not be big
48 // enough for the frame, and the morestack
49 // check in f2 will die, if we get that far
55 func f2() [3000]byte {
60 var c
= make(chan int)
62 var b
= []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
66 if len(ss
) != len(b
) {
67 panic("bad []byte -> string")
78 for i
:= 0; i
< len(t
); i
++ {
86 println("bad func", s
, "at level", n
)
96 for i
:= 0; i
< len(t
); i
++ {