go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.82k stars 2.14k forks source link

Delve Crashing #2449

Closed tlnsave12345 closed 3 years ago

tlnsave12345 commented 3 years ago

Please answer the following before submitting your issue:

Note: Please include any substantial examples (debug session output, stacktraces, etc) as linked gists.

  1. What version of Delve are you using (dlv version)? 1.6.0
  2. What version of Go are you using? (go version)? 1.16.2
  3. What operating system and processor architecture are you using? Windows, amd64
  4. What did you do? Trying to debug my application and the delve immediately crashes
  5. What did you expect to see? No crash
  6. What did you see instead? Crash

Here is the crash:

> C:\Users\User\go\bin\dlv.exe debug .
panic: runtime error: index out of range [1] with length 0

goroutine 12 [running]:
encoding/binary.littleEndian.Uint16(...)
        C:/tmprun/apr142021/test2/myproj/.deps/go/src/encoding/binary/binary.go:53
github.com/go-delve/delve/pkg/dwarf/line.(*formReader).next(0xc000ca07e0, 0xc0008e8060, 0x0)
        C:/Users/User/go/pkg/mod/github.com/go-delve/delve@v1.6.0/pkg/dwarf/line/parse_util.go:93 +0x811
github.com/go-delve/delve/pkg/dwarf/line.parseFileEntries5(0xc000ca06c0, 0xc0008e8060)
        C:/Users/User/go/pkg/mod/github.com/go-delve/delve@v1.6.0/pkg/dwarf/line/line_parser.go:234 +0x105
github.com/go-delve/delve/pkg/dwarf/line.Parse(0xc0005cd530, 0x2b, 0xc0008e8060, 0x0, 0x0, 0x1, 0x8, 0xc000ca0510)
        C:/Users/User/go/pkg/mod/github.com/go-delve/delve@v1.6.0/pkg/dwarf/line/line_parser.go:93 +0x32c
github.com/go-delve/delve/pkg/proc.(*BinaryInfo).loadDebugInfoMaps(0xc000060140, 0xc0006e20c0, 0xc000ed0000, 0x5136d8, 0x513800, 0xc0013e4000, 0x1fa151, 0x1fa200, 0xc0006cf750, 0x0)
        C:/Users/User/go/pkg/mod/github.com/go-delve/delve@v1.6.0/pkg/proc/bininfo.go:1610 +0x5d8
created by github.com/go-delve/delve/pkg/proc.loadBinaryInfoPE
        C:/Users/User/go/pkg/mod/github.com/go-delve/delve@v1.6.0/pkg/proc/bininfo.go:1315 +0x555
aarzilli commented 3 years ago

Do you have a binary file I can take a look at that does this?

tlnsave12345 commented 3 years ago

Thanks Alessandro. I narrowed down the crash to a logger file that has CGO code. I am attaching the module tar that also has the binary. Our application can run on Macos and Windows. But by mistake the Macos logger (logger_macosapp.go) is also compiled in. But shouldn't cause a crash.

exp1.tar.gz

aarzilli commented 3 years ago

Thank you, I'll take a look.

aarzilli commented 3 years ago

The executable you have sent me, eg1.exe, has severely broken debug symbols. I made a commit to address the symptoms, so that delve doesn't crash on it, but don't expect to ever be able to debug it, with delve or any other debugger. I think the underlying cause is that cgo doesn't officially support llvm (https://github.com/golang/go/issues/17014)