-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
This follows https://golang.org/cl/10268/ and includes more convoluted (harder to trigger, harder to fix) versions of the problems addressed there. "The problem" is that any time a stack allocation of pointer-containing data is converted to a heap allocation (this happens if the stack allocation is very large), the pointers stored in that data must be noted as escaping to heap. This works fine if the stack-to-heap conversion takes place before escape analysis, but not-fine if it occurs after escape analysis. In most cases conversion occurs during typechecking (before escape analysis) but in some cases walk (after escape analysis) performs transformations that are then type-checked. From josharian's comments on the CL above:
Here are some large (but not arbitrarily large) temps introduced during walk. Don't know whether they are of concern.
Up to 1024 bytes in convT2E (walk.go:1064)
Up to 2048 bytes in OMAKEMAP (walk.go:1441)
Up to 128 bytes in OSTRARRAYRUNE (walk.go:1559)
Here are what look to me like arbitrarily large temps introduced during walk, although I might be wrong:
In ascompatet in walk.go:1758. See also the todo at order.go:30. Code to reproduce:
package p
func g() ([10000]byte, error) {
switch { // prevent inlining
}
var x [10000]byte
return x, nil
}
func f() {
var e interface{}
var err error
e, err = g()
_, _ = e, err
}
Note that f uses 20048 bytes of stack.
reorder3save, at walk.go:2461. Code to reproduce:
package p
func g() [10000]byte {
switch {
} // prevent inlining
var x [10000]byte
return x
}
func f() {
var m map[[10000]byte]bool
m[g()] = true
}
Note that f uses 20016 bytes of stack.