awsome 在 2017年6月7日星期三 UTC+8下午4:25:35,Dave Cheney写道: > > Try building your program with -gcflags="-l" to disable inlining. If that > restores the stacktrace, then it's inlining. The good news is this should > be fixed with Go 1.9 > > On Wednesday, 7 June 2017 16:37:26 UTC+10, winlin wrote: >> >> Hi, I'm confused by the stack trace when panic, and I have searched both >> in history topics and google. >> If I use panic, the stack is fine, code is >> https://play.golang.org/p/Yb7fYW9ro3 , output is: >> >> panic: Panic from user >> >> goroutine 1 [running]: >> >> main.causedPanic() >> >> /tmp/sandbox078566511/main.go:11 +0x60 >> >> main.run() >> >> /tmp/sandbox078566511/main.go:7 +0x20 >> >> main.main() >> >> /tmp/sandbox078566511/main.go:4 +0x20 >> >> >> But if there is a runtime panic, the stack is completely unreadable, code >> is https://play.golang.org/p/MHKPG5uFFn , output is: >> >> panic: runtime error: invalid memory address or nil pointer dereference >> >> goroutine 1 [running]: >> >> main.main() >> >> /tmp/sandbox277759147/main.go:4 +0x4 >> >> >> If I add a defer to the last function, the stack comes back, code is >> https://play.golang.org/p/V7qDdyt_4Z , output is: >> >> panic: runtime error: invalid memory address or nil pointer dereference >> >> goroutine 1 [running]: >> >> main.causedPanic() >> >> /tmp/sandbox416089181/main.go:13 +0x48 >> >> main.run() >> >> /tmp/sandbox416089181/main.go:7 +0x20 >> >> main.main() >> >> /tmp/sandbox416089181/main.go:4 +0x20 >> >> >> Why it's diferent when there is a empty defer? It confused me. >> >>
-- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.