go-delve / delve

Delve is a debugger for the Go programming language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

debug with dlv can't continue on panics+defer recover properly

armstrongli opened this issue · comments

  1. What version of Delve are you using (dlv version)?
$ dlv version
Delve Debugger
Version: 1.22.0
Build: $Id: 61ecdbbe1b574f0dd7d7bad8b6a5d564cce981e9 $
  1. What version of Go are you using? (go version)?
$ go version
go version go1.21.1 darwin/amd64
  1. What operating system and processor architecture are you using?
macOS, 13.6.4 (22G513)
  1. What did you do?
debug sample snippet and get unexpected panics
  1. What did you expect to see?
no panics and continue debug
  1. What did you see instead?
stuck on panic stack forever
  1. code snippet can't debug, and stuck on panic
func TestPrintDebugPanic(t *testing.T) {
	tt := (*Foo)(nil)
	fmt.Printf("%v", tt)
}

type Foo struct {
	Bar
}

type Bar struct{}

func (Bar) String() string {
	return "bar"
}

panic stack:

Exception has occurred: runtime error
invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation]
Unable to propagate EXC_BAD_ACCESS signal to target process and panic (see https://github.com/go-delve/delve/issues/852)
Stack:
	0  0x000000000115a366 in github.com/ebayinc/esams-controller/tmp.(*Foo).String
	    at <autogenerated>:1
	1  0x00000000010d32e3 in fmt.(*pp).handleMethods
	    at /usr/local/go/src/fmt/print.go:673
	2  0x00000000010d41d3 in fmt.(*pp).printArg
	    at /usr/local/go/src/fmt/print.go:756
	3  0x00000000010d6b2a in fmt.(*pp).doPrintf
	    at /usr/local/go/src/fmt/print.go:1077
	4  0x00000000010d0338 in fmt.Fprintf
	    at /usr/local/go/src/fmt/print.go:224
	5  0x00000000010d04cf in fmt.Printf
	    at /usr/local/go/src/fmt/print.go:233
	6  0x0000000001159f38 in foo/tmp.TestPrintDebugPanic

Closing, duplicate of #852. This is caused by a limitation in old versions of debugserver, updating xcode would fix it.