delve: On macOS a SIGSEGV (EXC_BAD_ACCESS) can not be propagated back to the target

  1. What version of Delve are you using (dlv version)? Version: 1.0.0-rc.1
  2. What version of Go are you using? (go version)? go version go1.8.2 darwin/amd64 note: also occurs with 1.8.1
  3. What operating system and processor architecture are you using? OSX El Capitan
  4. What did you do? Attempt to debug go program that uses go-kit/kit/log
  5. What did you expect to see? Program runs normally
  6. What did you see instead? Program stops at go-stack/stack/stack.go/stack.go:228

Here is the source code:

package main

import (
	"os"
	"github.com/go-kit/kit/log"
)

func main() {
	log.NewLogfmtLogger(os.Stdout)
}

Here’s what the delve session looks like:

~/dev/go/src/mat/foo $ dlv debug
Type 'help' for list of commands.
(dlv) continue
> mat/vendor/github.com/go-stack/stack.findSigpanic.func1() /Users/mathewnelson/dev/go/src/mat/vendor/github.com/go-stack/stack/stack.go:228 (PC: 0x10b8ec3)
   223:						}
   224:					}
   225:				}
   226:			}()
   227:			// intentional nil pointer dereference to trigger sigpanic
=> 228:			return *p
   229:		}()
   230:		return fn
   231:	}
   232:	
   233:	var sigpanic = findSigpanic()
(dlv) 

This was working with 0.12.2.

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 12
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Is there any workaround for this? This is really a pain.

Note: even though this bug is closed you will continue to experience it until a version of debugserver with the corresponding patch is installed. At the time of this message no released version of xcode command line tools has it.

Here’s a simple solution on my mac to build debugserver from sourcecode:

git clone https://github.com/llvm/llvm-project.git   // download llvm source code (lldb source code inside)
git checkout llvmorg-12.0.1-rc4 # this version has already supported unmask_signals
brew install cmake # install cmake to build debugserver
cd llvm-project && mkdir zz && cd zz && cmake -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLDB_INCLUDE_TESTS=OFF   ../llvm #  use cmake to generate Makefile
make debugserver -j16 #  compile debugserver

The last step is to configure go-delve to use debugserver compiled above. Here are some possible solutions:

  1. If your go-delve version is earlier than v1.4.1, the debugserver path is an absolute path in go-delve, you need to either modify go-delve source code or overwrite debugserver binary. https://github.com/go-delve/delve/blob/81a86086dd9974d5bab76b1749d7450bb6b5cfab/pkg/proc/gdbserial/gdbserver.go#L300
  2. If your go-delve is v1.4.1 or later versions, then you can override environment variable PATH like
export PATH=${direcotry_path_of_newly_compiled_debugserver):$PATH
  1. If your go-delve is v1.6.1, you can set environment variable DELVE_DEBUGSERVER_PATH, dlv will use the value of this variable as the absolute path of debugserver.

I haven’t experienced this since upgrading to Go 1.15.4 🤞 I think https://github.com/golang/go/commit/1b49a86ecece3978ceba60c372327b9cbcc68501 may provide the workaround

Building the lldb debug server manually wasn’t straightforward or easy 😞