Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSX 10.10.3] Can't seem to be able to debug a program or attach to an existing one #159

Closed
keltia opened this issue Jun 30, 2015 · 16 comments
Labels
Milestone

Comments

@keltia
Copy link

keltia commented Jun 30, 2015

Running a process then attaching:

296 [13:56] roberto@roberto-aw> sudo dlv attach 59077
Password:
could not attach to pid 59077: could not get thread count
[Hope I was of service hunting your bug!]

The process to be attached is:

574 [13:55] roberto@roberto-aw:src/flightaware-go> ./bin/fa-export
2015/06/30 13:55:55 Connecting to foxtrot.hou.flightaware.com:1501 with TLS
2015/06/30 13:55:56 TLS negociation done.
2015/06/30 13:55:56 Flightaware init done.
2015/06/30 13:55:56 Waiting for data…
2015/06/30 13:55:56 Loop
[1]    59077 killed     ./bin/fa-export

trying to run the process through dlv:

572 [13:54] roberto@roberto-aw:src/flightaware-go> ll !$
ll bin/fa-export
-rwxr-xr-x  1 roberto  staff  5551876 Jun 30 12:06 bin/fa-export*
573 [13:54] roberto@roberto-aw:src/flightaware-go> dlv ./bin/fa-export
could not launch process: could not fork/exec
[Hope I was of service hunting your bug!]

Code is at https://github.com/keltia/flightaware-go/

@derekparker derekparker added this to the 1.0 milestone Jun 30, 2015
@derekparker
Copy link
Member

What OS are you running?

I was able to build and run through Delve with the following commands:

derekparker at flightaware-go(master) make
go build -v -o bin/fa-export fa-export/fa-export.go fa-export/cli.go
gopkg.in/yaml.v2
_/Users/derekparker/go/src/github.com/keltia/flightaware-go/config
_/Users/derekparker/go/src/github.com/keltia/flightaware-go/flightaware
command-line-arguments
derekparker at flightaware-go(master+) dlv bin/fa-export
Type 'help' for list of commands.
(dlv) b main.main
Breakpoint 1 set at 0x2300 for main.main /Users/derekparker/go/src/github.com/keltia/flightaware-go/fa-export/fa-export.go:36
(dlv) c
current loc: main.main /Users/derekparker/go/src/github.com/keltia/flightaware-go/fa-export/fa-export.go:36
   31:                  log.Fatalf("Error writing %d bytes: %v", nb, err)
   32:          }
   33:  }
   34:
   35:  // Starts here.
=> 36:  func main() {
   37:          // Handle SIGINT
   38:          go func() {
   39:              sigint := make(chan os.Signal, 3)
   40:              signal.Notify(sigint, os.Interrupt)
   41:              <-sigint

(dlv) Would you like to kill the process? [Y/n]
[Hope I was of service hunting your bug!]

@derekparker
Copy link
Member

@keltia I imagine some flavor of FreeBSD?

@keltia
Copy link
Author

keltia commented Jun 30, 2015

Nope, unless you consider OS X to be one (which it is in a way ok). I'm running OS X 10.10.3 as indicated in the subject line :)

@derekparker
Copy link
Member

@keltia ah, sorry... I'm still waiting on coffee to kick in ;).

I'm running the same system and I was able to pass along the path to Delve. I can attempt attaching to a running process and see if that makes any difference.

@keltia
Copy link
Author

keltia commented Jun 30, 2015

could not launch process: could not fork/exec seems to indicate some kind of resource shortage but the rest of the system does work.

@derekparker
Copy link
Member

@keltia have you gone through the process of code signing the dlv binary?

@keltia
Copy link
Author

keltia commented Jun 30, 2015

Yes, created a fake self-signed root cert and signed. I could also have used my own certificate but didn't thought of that.

@derekparker
Copy link
Member

I am unable to reproduce this issue, I was able to attach to the binary by passing along the path.

Have you been able to use Delve successfully on your machine before? Could you try dlv run on an extremely simple test program and verify that it works?

If it does not work with a simple test program than I honestly suspect it is an issue with the cert.

@derekparker
Copy link
Member

Closing as related to #134.

@ObviousDesign
Copy link

Thanks for writing this great piece of software! Just compiled it on OSX 10.11 following all the required steps. I have the same issue when launching a debug session:

$ dlv debug main.go
could not launch process: could not fork/exec

The way I was able to resolve this is by running the command as sudo.

$ sudo dlv debug main.go
Password:
Type 'help' for list of commands.
(dlv)

@derekparker
Copy link
Member

@ObviousDesign thanks for checking it out! The debug subcommand actually does not take an argument, it expects to be run where you would run go build without any args. Secondly, since sudo worked for you, it seems there is an issue with how the dlv binary was codesigned. For sanity checks, did you make sure you killed the taskgated process? Also, the output of make install could be useful here.

@ObviousDesign
Copy link

Hi @derekparker, I was not able to kill the taskgated process before compiling first time. Now recompiled after a fresh restart and I am now able to run dlv without sudo. Thank you for your support. Jeroen

@notnil
Copy link

notnil commented Mar 4, 2016

I had the same issue and it was related to taskgated. I just restarted and everything worked.

@jkowalski
Copy link

FWIF I had similar issue today:

"sudo dlv exec ./blah" worked fine, but "dlv exec ./blah" would print the dreaded "could not launch process: could not fork/exec".

I double checked that the certificate was configured properly and that dlv was properly signed. Restarting taskgated did not help in my case.

What helped was - surprisingly - starting XCode. Apparently the first time it starts, it installs some debugging support tools, which seems to allow dlv to run as regular user.

@helinwang
Copy link

Make sure each time you try the code sign, run sudo pkill taskgated first.

@MariMurotani
Copy link

I have same problem that I get error below except root user.
could not launch process: could not fork/exec
I killed taskgated just before make, but taskgated restarts after make process.

OS: OSX Yosemite 10.10.4
Darwin Kernel Version 14.4.0

In addition, after renamed these files, I am not able to run codesign.
/System/Library/LaunchDaemons/com.apple.taskgated-helper.plist
/System/Library/LaunchDaemons/com.apple.taskgated.plist

[root]$ codesign -s "dlv-cert" /Users/murotanimari/work/bin/dlv
error: One or more parameters passed to a function were not valid.

nclifton pushed a commit to nclifton/delve that referenced this issue Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants