文章目录
- [Goland Debug 模式崩溃](#Goland Debug 模式崩溃)
Goland Debug 模式崩溃
有时遇到如下现象: Golang Run 模式正常,Debug 无 BreakPoint 模式正常,但 Debug 加 BreakPoint 就会偶现 panic,panic 信息如下。
go
panic: runtime error: index out of range [7] with length 0
goroutine 112 [running]:
encoding/binary.littleEndian.Uint64(...)
/opt/buildAgent/temp/buildTmp/go/src/encoding/binary/binary.go:77
github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbRegisters).SP(0xc000353ef8, 0xc0006bfc10)
/opt/buildAgent/work/4c3e5e3eabfaf2d2/pkg/proc/gdbserial/gdbserver.go:1810 +0x85
github.com/go-delve/delve/pkg/proc.funcCallStep(0xc0025941e0, 0xc0006bfc10, 0x17255d8, 0xc000353ee0, 0xc, 0xc00244aac8, 0x13, 0x0)
/opt/buildAgent/work/4c3e5e3eabfaf2d2/pkg/proc/fncall.go:834 +0x74c
github.com/go-delve/delve/pkg/proc.evalFunctionCall(0xc0025941e0, 0xc0007bd140, 0xc000065cf0, 0x109cb76, 0x171e560)
/opt/buildAgent/work/4c3e5e3eabfaf2d2/pkg/proc/fncall.go:358 +0xa65
github.com/go-delve/delve/pkg/proc.(*EvalScope).evalAST(0xc0025941e0, 0x171d990, 0xc0007bd140, 0x1, 0x1, 0x64)
/opt/buildAgent/work/4c3e5e3eabfaf2d2/pkg/proc/eval.go:708 +0x312
github.com/go-delve/delve/pkg/proc.(*EvalScope).EvalExpression(0xc0025941e0, 0xc002b69740, 0x12, 0x1, 0x1, 0x64, 0x64, 0xffffffffffffffff, 0x0, 0x0, ...)
/opt/buildAgent/work/4c3e5e3eabfaf2d2/pkg/proc/eval.go:181 +0x69e
created by github.com/go-delve/delve/pkg/proc.EvalExpressionWithCalls
/opt/buildAgent/work/4c3e5e3eabfaf2d2/pkg/proc/fncall.go:197 +0x356
Debugger finished with the exit code 2
其实 Goland 和 VsCode 的 Debug 都是基于 delve 实现的
解决方案:
- 重装最新版 Goland,安装最新版 go(如 brew upgrade go)
- 查看 dlv 版本(which dlv),源码安装 dlv,实测卸载 dlv 后 Goland 也可以跑起来