-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
This program: package main func main() { var pad [28*100]byte a := 0 b := 10 / a println(b) println(len(pad)) } outputs this: runtime: split stack overflow: 0x1084a5a8 < 0x1084a800 throw: runtime: split stack overflow runtime.throw+0x42 /root/hg/go/src/pkg/runtime/runtime.c:102 runtime.throw(0x41f365, 0x1084a5a8) runtime.newstack+0x9b /root/hg/go/src/pkg/runtime/proc.c:741 runtime.newstack() runtime.morestack+0x4c /root/hg/go/src/pkg/runtime/386/asm.s:220 runtime.morestack() ----- morestack called from goroutine 1 ----- runtime.sigtramp1+0x19 /root/hg/go/src/pkg/runtime/windows/386/sys.s:68 runtime.sigtramp1(0x1084a5c4, 0x1084a5d0, 0x77fbb272, 0x1084a670, 0x6ffbc, ...) runtime.sigtramp+0xd /root/hg/go/src/pkg/runtime/windows/386/sys.s:63 runtime.sigtramp() ----- goroutine created by ----- _rt0_386+0xbf /root/hg/go/src/pkg/runtime/386/asm.s:80 goroutine 1 [2]: runtime.mainstart /root/hg/go/src/pkg/runtime/386/asm.s:91 runtime.mainstart() runtime.goexit /root/hg/go/src/pkg/runtime/proc.c:178 runtime.goexit() ----- goroutine created by ----- _rt0_386+0xbf /root/hg/go/src/pkg/runtime/386/asm.s:80 I expect output to be different. And similar program: package main func main() { var pad [20*100]byte a := 0 b := 10 / a println(b) println(len(pad)) } outputs correct text: panic: runtime error: integer divide by zero [signal 0xc0000094 code=0x1003f addr=0x0 pc=0x40103a] runtime.panic+0x9e /root/hg/go/src/pkg/runtime/proc.c:1060 runtime.panic(0x40e66c, 0x10840000) runtime.panicstring+0x94 /root/hg/go/src/pkg/runtime/runtime.c:116 runtime.panicstring(0x41e822, 0xb) runtime.sigpanic+0xc5 /root/hg/go/src/pkg/runtime/windows/thread.c:279 runtime.sigpanic() main.main+0x3a /home/sambauser/pub/t2/a.go:6 main.main() runtime.mainstart+0xf /root/hg/go/src/pkg/runtime/386/asm.s:93 runtime.mainstart() runtime.goexit /root/hg/go/src/pkg/runtime/proc.c:178 runtime.goexit() ----- goroutine created by ----- _rt0_386+0xbf /root/hg/go/src/pkg/runtime/386/asm.s:80 I think this is what happens: 1) division by zero occurs and exception is raised; 2) Windows exception handler runs, it puts some data on the stack; 3) Windows exception handler calls our exception handler runtime.settramp; 4) runtime.settramp calls runtime.settramp1; 5) as runtime.settramp1 is not '#pragma textflag 7', it will try to check stack only to discover that it is overflown; 6) CRASH! My: hd id is 29f6e2e230a3, GOARCH is 386 GOOS is windows Alex