Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

debugger does not stop the process #604

Closed
zrhmn opened this issue Nov 4, 2016 · 2 comments
Closed

debugger does not stop the process #604

zrhmn opened this issue Nov 4, 2016 · 2 comments
Assignees
Labels

Comments

@zrhmn
Copy link

zrhmn commented Nov 4, 2016

In addition to #360 I am having a problem where if a go program enters an infinite loop, or in a similar fashion, is http.ListenAndServeing, stopping the debug process fails to properly kill the debug process running.

For example here's a program:

package main

import (
	"fmt"
	"log"
	"net/http"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Hello, world!\r\n")
	})

	log.Fatal(http.ListenAndServe(":2080", nil))
}

Here's the corresponding launch.json

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Launch",
			"type": "go",
			"request": "launch",
			"mode": "debug",
			"port": 20552,
			"program": "${workspaceRoot}",
			"env": {},
			"args": [],
			"showLog": true
		}
	]
}

(http.ListenAndServe() runs a for { /* ... */ } loop under the hood. Apart from the other issue (#360) when I start debugging, it works as expected. The server starts listening and responding to the fact. However, when I press stop (▪) the debugger appears to stop, but the underlying process that the debugger had started, continues to run. I noticed this because when I started debugging again, the program could not bind to the specified port because it was already in use. I checked and found that the previous process was still running.

Example:

$ ### right after debugging was started ###
$ ps aux | grep '/debug'
zia      23955  1.3  0.3 865464 51912 ?        Sl   02:44   0:00 /usr/share/code/code /usr/share/code/resources/app/out/vs/base/node/stdForkStart.js /home/zia/.vscode/extensions/lukehoban.Go-0.6.47/out/src/debugAdapter/goDebug.js
zia      24003  0.0  0.0 110168  4584 ?        Sl   02:44   0:00 /home/zia/go/dbg_test/debug
zia      24025  0.0  0.0  10408  1612 pts/17   S+   02:44   0:00 grep --colour=auto /debug
$
$ ### after debugging was stopped ###
$ ps aux | grep '/debug'
zia      24003  0.0  0.0 110168  4584 ?        Sl   02:44   0:00 /home/zia/go/dbg_test/debug
zia      24047  0.0  0.0  10408  1620 pts/17   S+   02:45   0:00 grep --colour=auto /debug

Note that this issue can be reproduced with a program as simple as:

package main

func main() {
	for {
	}
}

Apparently, the only requirement for reproducing the bug is an infinite loop. Programs that are supposed to exit naturally are not affected (although they don't stop at breakpoints because of #360 but that's another issue).


Here's some other information that may be helpful:

OS: Linux Mint 17.2 (Ubuntu 14.04)
VSCode version: 1.7.1 (02611b40b24c9df2726ad8b33f5ef5f67ac30b44)
VSCode go version: 0.6.46
Go version: 1.7.3
Delve version: 0.11.0-alpha

@YLivay
Copy link

YLivay commented Dec 12, 2016

Can confirm, Sending SIGKILL instead of the default SIGTERM here might be a workaround but I'm not sure how important it is to terminate the debug processes gracefully. Might not work if dlv spaws the process in detached mode. Will compiling the extension and test.

@ramya-rao-a
Copy link
Contributor

Closing as duplicate of #438

We are trying to get a fix for this in the next update.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants