The asm function `Sum` try call a Go function `sum`,
when the `sum` need morestack, it crashed:
// main.go
func main() {
println(Sum(100))
println(Sum(100 * 1000)) // panic!
}
func Sum(n int) int
func sum(i, j int) int {
if i <= 0 {
return j
}
return sum(i-1, i+j)
}
// main_amd64.s
TEXT ·Sum(SB), $24-16
MOVQ n+0(FP), AX
MOVQ AX, 0(SP)
MOVQ $0, 8(SP)
CALL ·sum(SB)
MOVQ 16(SP), AX
MOVQ AX, ret+8(FP)
RET
panic message:
Sum(100): 50005000
runtime: frame ... untyped locals 0xc042233e88+0x18
fatal error: missing stackmap
runtime stack:
runtime.throw(0x467c4b, 0x10)
C:/go/go1.7.windows-amd64/src/runtime/panic.go:566 +0x9c
runtime.adjustframe(0x6fb40, 0x6fc38, 0x6f901)
C:/go/go1.7.windows-amd64/src/runtime/stack.go:660 +0x7d2
runtime.gentraceback(0xffffffffffffffff, 0xc0421b52b0, 0x0, 0xc04201c000, 0x0, 0x0, 0x7fffffff, 0x46d898, 0x6fc38, 0x0, ...)
C:/go/go1.7.windows-amd64/src/runtime/traceback.go:378 +0x10aa
runtime.copystack(0xc04201c000, 0x100000, 0x6fe01)
C:/go/go1.7.windows-amd64/src/runtime/stack.go:902 +0x388
runtime.newstack()
C:/go/go1.7.windows-amd64/src/runtime/stack.go:1070 +0x37e
runtime.morestack()
C:/go/go1.7.windows-amd64/src/runtime/asm_amd64.s:366 +0x87
...
Thanks!
--