return nBackendWorkers == 1 && Debug_compilelater == 0
}
+const maxStackSize = 1 << 31
+
// compileSSA builds an SSA backend function,
// uses it to generate a plist,
// and flushes that plist to machine code.
ssafn := buildssa(fn, worker)
pp := newProgs(fn, worker)
genssa(ssafn, pp)
- if pp.Text.To.Offset < 1<<31 {
+ if pp.Text.To.Offset < maxStackSize {
pp.Flush()
} else {
largeStackFramesMu.Lock()
e := f.Frontend().(*ssafn)
- // Generate GC bitmaps.
- s.stackMapIndex = liveness(e, f)
+ // Generate GC bitmaps, except if the stack is too large,
+ // in which compilation will fail later anyway (issue 20529).
+ if e.stksize < maxStackSize {
+ s.stackMapIndex = liveness(e, f)
+ }
// Remember where each block starts.
s.bstart = make([]*obj.Prog, f.NumBlocks())
"issue18882.go", // go/types doesn't check validity of //go:xxx directives
"issue20232.go", // go/types handles larger constants than gc
"issue20227.go", // go/types does not handle this yet
+ "issue20529.go", // go/types does not have constraints on stack size
)
}
--- /dev/null
+// errorcheck
+
+// +build amd64
+
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 20529: Large stack frames caused compiler panics.
+// Only tested on amd64 because the test only makes sense
+// on a 64 bit system, and it is platform-agnostic,
+// so testing one suffices.
+
+package p
+
+func f() { // ERROR "stack frame too large"
+ _ = [][]int{1e9: []int{}}
+}