Please answer the following before submitting your issue:
Note: Please include any substantial examples (debug session output,
stacktraces, etc) as linked gists.
dlv version)?go version)?From terminal:
joefrancia@iMac [6:17:20]: dlv debug
could not launch process: could not get thread count
I believe it may be related to the upgrade from Sierra beta 1 to beta 2. I was debuggin a'plenty earlier in the afternoon on my MacBook which was still on beta 1, but when I tried on the iMac I got the above failure. The iMac is beta 2. I've since upgraded the MacBook to beta 2 (this was before I realized there may be a problem) and now I get the same error on the MacBook.
Exactly the same here.Same set-up,same issue.The only difference here is that my golang environment is newly installed after I installed Mac OS 10.12 Beta2
This problem from after the Developer beta.(16.1.0: xnu-3789.21.3~20)
It does not occur Sierra stable(16.0.0: xnu-3789.1.32~3)
https://github.com/derekparker/delve/blob/master/proc/proc_darwin.c#L108-L109
count is almost(why?) 0. sometimes got 28672 or etc.
But kret is not KERN_SUCCESS, In my case, always got 268435459.
I'll try to debug it.
Edit: 268435459 is MACH_SEND_INVALID_DEST
@aarzilli I did a clean install Sierra stable(10.12.0 - 16.0.0: xnu-3789.1.32~3) for debug to this problem. That certainly no problem on stable.
BTW, Apple has been released 10.12.1(today?). I do not yet test. I'll test on the VMWare.
If occur same error on 10.12.1, This is not a bug, specification change. We need to be deal it.
However, If many projects(lldb, radare2, mono or etc) using the same logic, it might have the same problem. We can get a hint from there.
I have no problem on 10.12 at all, but after I updated to 10.12.1 today, the problem occurred.
Confirmed that update to 10.12.1 broke it.
go version: go1.7.3 darwin/amd64, dlv version: Version: 0.11.0-alpha
@aarzilli I understood why the behavior of the Mach task has been changed. It seems for the deal to the vulnerability(exploit).
I only make the kernel debug environment on vmware, not yet tried to fix the code.
I do not know whether the same logic can be used. But there is a different method of obtaining the task state, I'll try it.
Same here. Just update the MacOS cannot run again.
Updated to Mac OS X 10.12.1 and started seeing this problem.
"/Users/dieterlyd/Library/Application Support/IntelliJIdea2016.2/Go/lib/dlv/mac/dlv" --listen=localhost:50875 --headless=true exec "/private/var/folders/v9/04pc_rsn0gz47hd_ql7r78gm0000gn/T/Build main.go and rungo" --
GOROOT=/usr/local/go
GOPATH=/Users/dieterlyd/Documents/go
/usr/local/go/bin/go build -o "/private/var/folders/v9/04pc_rsn0gz47hd_ql7r78gm0000gn/T/Build main.go and rungo" -gcflags "-N -l" /Users/dieterlyd/Documents/firstGoProject/main.go
could not launch process: could not get thread count
I'm also seeing this issue on 10.12.1 "Delve output: could not launch process: could not get thread count"
update the MacOS to 10.12.1 cannot run again ,:)
Having the same issue with Mac OS 10.12.1.
Is there any solution to this? besides downgrading the OS?
Same here. :(
Here is related information for this issue.
Chromium bug report: task_t considered harmful - many XNU EoPs
Blog post: task_t considered harmful
@rustyrobot Yeah.
I was some kernel debugging with vmware. I can found source line number, but xnu-3789.21.3~60 is not published yet, so I cannot know what added behavior.
callgraph is
task_threads -> convert_thread_to_portIt seems to occured ulock(?) on convert_thread_to_port. After that, failed(not return KERN_SUCCESS) task_threads function.
That’s all I know now.
New (week-old) Sierra full install (no upgrade). Go debug in VSCode was all things beautiful. Today after 10.2.1 update--absolutely no other changes--now no more VSCode joy.
2016/10/31 20:23:36 server.go:71: Using API v1
2016/10/31 20:23:36 debugger.go:61: launching process with args: [./debug]
could not launch process: could not get thread count
Same here
Please stop reporting again and again. It is confirmed that delve is now broken on macOS 10.12.1.
Still broken on 10.12.2, looks like the change might stick.
I think its still broken :( No luck
same
@aarzilli I have no time for debugging this issue but found Apple official hints.
Xcode 8.1 Release Notes - Debugging
Starting with macOS Sierra 10.12.1, Xcode 8.1 is required to debug processes that call exec() on themselves. On older Xcode versions, re-attach the debugger to the target process after the exec()] call. (28476369)
Maybe (28476369) means <rdar://problem/28476369>, same as LLDB's commit message.
I think we can solve this issue use <Availability.h> and __MAC_10_12_1 macro, and fix fork_exec behavior.
For ALL
This is caused by Security Update for execute arbitrary code with root privileges.
macOS Sierra 10.12.1, Security Update 2016-002 El Capitan, and Security Update 2016-006 Yosemite
It is unlikely that Apple will deal with backward compatibility in the future. We need to change the delve internal.
As @l2dy said, Really please stop short reporting again.
I have tried as @zchee wrote:
On older Xcode versions, re-attach the debugger to the target process after the exec()] call.
It works well!
please see this commit
I just tried locally and @bx-zhanjh your branch works like expected. Thanks 👍
fuck osx
@bx-zhanjh thanks! Your branch works perfect, why not do a pull request? Initially installed Delve through brew and had this exact problem. Fixed it by then following the simple instructions to build his branch. Now I've got Webstorm perfectly working with Delve on go 1.7 👍
Just FYI for people who also use Webstorm as their IDE, make sure you symlink to the custom one you've built: ln -s $GOPATH/bin/dlv ~/Library/Application Support/WebStorm2016.3/Go/lib/dlv/mac because Webstorm sends along their own version of delve.
I believe some are too lazy to build it themselves. So here is a zip file containing the executable which seems to work on Mac OS 10.21.1 using go version go1.7.3 darwin/amd64. I hope it helps some of you out there. EDIT: Yep, totally forgot the signature thing. Anyways, @amkoehler has outlined what you need to do to get it working.
Thank you!
@iain17 use you dlv.zip -> could not launch process: could not attach to 31045 ?
@zuojinmin @iain17 I don't think you can just re-use the signed binary like this. I think you need to re-sign it first using your own code-signing cert, i.e:
codesign -s dlv-cert -f dlv
(where "dlv-cert" is the certificate you created)
i rebuild with bx-zhanjh's commit , but it's still type out "could not launch process: could not get thread count"
Intellij idea 2016.2
I've had some luck using PR #665 from @aarzilli. It is still being worked on and you may experience some performance issues and random failures. I haven not had any issues yet but you should be aware of the risks. From a fresh install all you have to do is check out the PR and re-build.
git clone https://github.com/derekparker/delve.git && cd delvegit clone https://github.com/derekparker/delve.git && cd delve check out the PR:git fetch origin pull/665/headgit checkout FETCH_HEADCERT=dlv-cert make install. @helyho, make sure you clean out your $GOPATH/lib directory. I've used @bx-zhanjh's commit successfully with IntelliJ Idea 2016.2.
On that note, I'm seconding @iain17's ask for a @bx-zhanjh submit a pull request. Anecdotally, I've been using it for as long as it's been up, and haven't had a single problem with it.
@andrewksl see #665
@bx-zhanjh , Thank you very much!! you resolved my big problem!
my step:
and run dlv debug, it's run ok~
@pangsscn as you say ,it`s ok
but show this message
could not launch process: could not attach to 40823
@zuojinmin, Yes me too~ but you can sudo dlv debug to debug your program~
@bx-zhanjh , and I have new question... as my normal user, run dlv debug ,show me"could not launch process: could not attach to 40319" but run "sudo dlv debug", show me"Type 'help' for list of commands.(dlv) ". and I can debug now~ How can I debug with my NONE ROOT user?
Same Here.
@pangsscn I also met the save problem when using delve in vscode, it can't be stopped by clicking the stop button.
@applee 写中文吧,我也一样但是能debug啊 ,等一会会自动停止 拉取BX-zhanjh 的分支
Using @aarzilli and @amkoehler nice fix above, the one with
...
"git fetch origin pull/665/head"
"git checkout FETCH_HEAD"
...
etc , above
Using delve via the lukehoban v0.6.49 extension to Visual Studio Code, and I will eventually end up with with a number of processes that appears never complete.

I can't recall having seen it on 10.11.
Is the problem with hanging processes known? (and will it be fixed with this thread count bug)
finally, it works;
thanks @aarzilli .great work .
My step:
GOPATH$GOPATH/src/github.com/derekparker/, and go into this folder.git clone https://github.com/derekparker/delve.gitcd delvegit fetch origin pull/665/headgit checkout FETCH_HEADCERT=dlv-cert make install@helyho, Great Work~ It can run with vscode, but it can't run in termainl....
@pangsscn works as expected in terminal as well; make sure you run the one you built in $GOPATH - e.g. $GOPATH/bin/dlv debug ...
@helyho I installed delve via homebrew, should I uninstalled broken version?
@helyho I installed delve via homebrew, should I uninstalled broken version?
Installing delve using homebrew will install the production release. It won't install the development version of homebrew, and not an independent branch.
Until #665 is pulled in, and another release is sent out, brew install delve won't fix this bug.
thanks for @helyho
@helyho
Currently getting the following with your method:
CERT=dlv-cert make install
go install -ldflags="-s -X main.Build=a1f31a83b4a295322b8b59327338b7d3311e6766" github.com/derekparker/delve/cmd/dlv
codesign -s "dlv-cert" /Users/willis7/Code/go/bin/dlv
error: The specified item could not be found in the keychain.
make: *** [install] Error 1
@willis7 Create a self-signed certificate first https://github.com/derekparker/delve/blob/master/Documentation/installation/osx/install.md
@helyho, Great Work~ It can run with vscode and terminal.
go into your GOPATH
create folder $GOPATH/src/github.com/derekparker/, and go into this folder.
'cd $GOPATH/src/github.com/derekparker/'
git clone https://github.com/derekparker/delve.git
cd delve
git fetch origin pull/665/head
git checkout FETCH_HEAD
CERT=dlv-cert make install
@l2dy Thank you, this worked.
To get this working with intellij IDEA 2016.3
$ mv ~/Library/Application\ Support/IntelliJIdea2016.3/Go/lib/dlv/mac/dlv ~/Library/Application\ Support/IntelliJIdea2016.3/Go/lib/dlv/mac/dlv.orig
$ ln -s $GOPATH/bin/dlv ~/Library/Application\ Support/IntelliJIdea2016.3/Go/lib/dlv/mac/dlv
Here we backup the original dlv binary, then create a symlink to the newly built PR version. I expect this will also work for any derivitive of Intellij IDEA.
@willis7 I've tried this in the past with IntelliJ 2 and same this time around as well:
/usr/local/Cellar/go/1.7/libexec/bin/go build -o /private/var/folders/3d/wh781qw542zg_7s254jlk2s40000gn/T/crayolago -gcflags "-N -l"
could not launch process: could not fork/exec
Process finished with exit code 1
So, can we get this merged and then we can send a message over to the go-lang-idea-plugin team so they can get this fix in?
According to their guide the go-lang-idea-plugin state that you can use:
-Dorg.gradle.project.customDlvPath
to use a custom build of delve.
I got delve working with a combination of @willis7 @l2dy @helyho 's instructions on Intellij. Thanks guys.
amkoehler commented worked for me~. Followed steps and added extra:
ln -s $GOPATH/bin/dlv ~/Library/Application Support/IntelliJIdea2016.3/Go/lib/dlv/mac
It worked in IntelliJ 2016.3 & Go 1.7.3
@pangsscn worked for me ~ thx~
git clone https://github.com/bx-zhanjh/delve.git src/github.com/derekparker/delve
cd src/github.com/derekparker/delve
git checkout origin/new_fork_exec
CERT=dlv-cert make install
@pangsscn @imnotanderson I use it in macOS 10.12.1 vscode 1.8.0 go 1.7.4 ,and it worked for me too! thx!
两个多月了,已经熟练掌握printf调试
@liu-junyong print调试太难受了,还是等修复吧
new_fork_exec doest work for me with 10.12.1 and xcode 8.1
@willis7
CERT=dlv-cert make install
go install -ldflags="-s -X main.Build=a1f31a83b4a295322b8b59327338b7d3311e6766" github.com/derekparker/delve/cmd/dlv
codesign -s "dlv-cert" /Users/willis7/Code/go/bin/dlv
error: The specified item could not be found in the keychain.
make: *** [install] Error 1
if you got this error mean comple source file finished and sign dlv file error ,so you need to find out which folder container dlv ,and go in this folder run codesign -s "dlv-cert" dlv to sign this executable file.
macOS Sierra (10.12.1)/IntelliJ Idea 2016.3 - having same issue:
_could not launch process: could not get thread count_
@pangsscn @imnotanderson I got the same as @zuojinmin got:
could not launch process: could not attach to 41423
@imnotanderson now when your debugging it runs program before continue, so I just cant break main.main
package main
import "fmt"
func main() {
fmt.Println("vim-go")
for {
}
}
Terminal
dlv debug
vim-go
Type 'help' for list of commands.
(dlv)
Or
dlv debug
vim-go
could not launch process: could not attach to 22574
If you run code without for loop
@freezlite , are you on a developer preview of macOS? Because I had this issue on latest developer preview but on stable it works fine with the @aarzilli 's fix
@AlexejK I used @imnotanderson sugestion
@helyho works on macOS 10.12.2 (16C67).
it works,thanks
$ ln -s $GOPATH/bin/dlv ~/Library/Application\ Support/IntelliJIdea2016.3/Go/lib/dlv/mac/dlv
Just want to throw this in here as an alternative to manually checking out and installing the HEAD version. If you use Homebrew, you can use this to get the HEAD version and automatically generate the cert:
brew install go-delve/delve/delve --HEAD
If you used Homebrew previously to install delve, I'd recommend running brew uninstall delve first before running the above command.
@deejross you sir are a genius. Delve is finally working for me now. /hattip
I'm using IntelliJ IDEA 2016.3.1
These additional steps were required to make it work from IDE:
$ mv ~/Library/Application\ Support/IdeaIC2016.3/Go/lib/dlv/mac/dlv ~/Library/Application\ Support/IdeaIC2016.3/Go/lib/dlv/mac/dlv_prev
$ ln -s $GOPATH/bin/dlv ~/Library/Application\ Support/IdeaIC2016.3/Go/lib/dlv/mac/dlv
I have the same issue with vs code, tried HEAD is not working
@deejross Thank soooooooo much.
System : macos 10.12.2
Those of you who have gotten this to work in OSX 10.12.2, can you look at my gist and see if you can tell what I'm doing wrong? I'm still getting thread forking/stopping issues. I would GREATLY appreciate it! @leejaedus @paincompiler
https://gist.github.com/aaronhackney/7d55323af7b5330607e80b7815bb7a10
10.2.3...same issue...any clues?
@rodriguise My issue was that FalconHost (anti-malware) was interfering. My writeup is here: https://github.com/aaronhackney/delve_on_mac Good luck!
after https://github.com/aaronhackney/delve_on_mac
I still have this problem @aaronhackney
Followed uninstall / install step indicated by @deejross -- And got bit by this bug instead... DOH! -- Fix for me was to uninstall and reinstall without --head... turns out the bug exists with the build I had 11.x but is fixed in the latest stable 12.1
@deejross worked with the addition of this for IntelliJIdea15 - I suspect anyone running an ide that uses its own dlv will have to do this. Thanks @crocusowl for the direction
$ cd ~/Library/Application Support/IntelliJIdea15/Go/lib/dlv/mac/
$ mv dlv dlv.orig
$ ln -s $HOMEBREW_PREFIX/bin/dlv .
Updating go plugin in IntelliJ helped me solve this issue
First, you can install delve debugger on your mac, like
$ brew install go-delve/delve/delve --HEAD
then, if you can debug with command line by
$ /usr/local/bin/dlv debug hello
Type 'help' for list of commands.
(dlv) break main.main
Breakpoint 1 set at 0x1086fc8 for main.main() ./src/hello/hello.go:5
(dlv) continue
> main.main() ./src/hello/hello.go:5 (hits goroutine(1):1 total:1) (PC: 0x1086fc8)
1: package main
2:
3: import "fmt"
4:
=> 5: func main() {
6: fmt.Println("Hello, world")
7: c := make(chan struct{}, 1)
8: go func() {
9: fmt.Println("start 1")
10: <-c
(dlv)
that we can confirm delve is running correctly. Let's show the version about delve
$ dlv version
Delve Debugger
Version: 0.12.1
Build: bb07fc36b9df2b9baec074ee8a48b1941f049f55
Ok, let's do
$ mv ~/Library/Application\ Support/IdeaIC2016.3/Go/lib/dlv/mac/dlv ~/Library/Application\ Support/IdeaIC2016.3/Go/lib/dlv/mac/dlv_bak
$ ln -s $PATH/dlv ~/Library/Application\ Support/IdeaIC2016.3/Go/lib/dlv/mac/dlv
and it works on my OSX 10.12.3.
@tommy-zhouketao , your procedure still doesn't work for me :( and am still experiencing https://github.com/derekparker/delve/issues/714.
Using version to confirm latest commit was built and installed:
~ dlv version
Delve Debugger
Version: 0.12.1
Build: ab7367ed2bf15044f7bca97147a802f77b875797
but I get:
➜ go/src/hello dlv debug
could not launch process: could not suspend thread 11523 (ipc/send) invalid destination port (additionally could not update thread list: could not get thread count)
with the file $GOPATH/src/hello/hello.go:
package main
import "fmt"
func main() {
fmt.Println("Hello, world")
c := make(chan struct{}, 1)
<- c
}
go get github.com/derekparker/delve/cmd/dlv
cd src/github.com/derekparker/delve/cmd/dlv
go build
go install
ok, it's works!
@linuxcer
works for my mac 10.12.6 (16G29)
go get github.com/derekparker/delve/cmd/dlv
cd src/github.com/derekparker/delve/cmd/dlv
go build
go install
Most helpful comment
finally, it works;
thanks @aarzilli .great work .
My step:
GOPATH$GOPATH/src/github.com/derekparker/, and go into this folder.git clone https://github.com/derekparker/delve.gitcd delvegit fetch origin pull/665/headgit checkout FETCH_HEADCERT=dlv-cert make install