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

Program hangs at start on "Start Without Debugging" #1084

Closed
realityexists opened this issue Jul 12, 2017 · 10 comments
Closed

Program hangs at start on "Start Without Debugging" #1084

realityexists opened this issue Jul 12, 2017 · 10 comments

Comments

@realityexists
Copy link

VS Code 1.14.0, Go extension 0.6.62, Go 1.8.3, dlv 1.0.0-rc.1 on Windows 7 x64

Whenever I try to run a program using "Start Without Debugging" (Ctrl+F5) the Debug Console window shows

2017/07/12 13:34:58 server.go:73: Using API v1
2017/07/12 13:34:58 debugger.go:97: launching process with args: [...\hello\debug]
API server listening at: 127.0.0.1:2345

and stops there. The program appears to be running, because the toolbar with pause, stop, etc. buttons appears, but no further output is shown. Process Hacker also shows the "debug" process still running, with "dlv.exe" as its parent. This happens even for the simplest "Hello world" program, like this.

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello world")
}

If I press Enter at the Debug Console prompt I get this error:

TypeError: Cannot read property 'currentGoroutine' of null
    at GoDebugSession.evaluateRequest (C:\Users\Rey\.vscode\extensions\lukehoban.go-0.6.62\out\src\debugAdapter\goDebug.js:668:45)
    at GoDebugSession.DebugSession.dispatchRequest (C:\Users\Rey\.vscode\extensions\lukehoban.go-0.6.62\node_modules\vscode-debugadapter\lib\debugSession.js:430:22)
    at GoDebugSession.ProtocolServer._handleData (C:\Users\Rey\.vscode\extensions\lukehoban.go-0.6.62\node_modules\vscode-debugadapter\lib\protocol.js:104:38)
    at Socket.<anonymous> (C:\Users\Rey\.vscode\extensions\lukehoban.go-0.6.62\node_modules\vscode-debugadapter\lib\protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at Pipe.onread (net.js:551:20)

The error looks like the same error as #473, except I only get this when trying to run without the debugger (Ctrl+F5). It works if I run under the debugger (F5).

I don't understand why the debugger (dlv.exe) is running at all when I've selected "Start Without Debugging"!

@lansman
Copy link

lansman commented Jul 12, 2017

Have the same issue.

Simpliest project

package main

import "fmt"

func main() {
	fmt.Print("enter a number: ")
	var input float64
	fmt.Scanf("%f", &input)

	output := input * 2
	fmt.Println(output)
}

Start it by F5 or ctrl+F5, enter number 123, hit Enter, got

TypeError: Cannot read property 'currentGoroutine' of null
    at GoDebugSession.evaluateRequest (C:\Users\doc\.vscode\extensions\lukehoban.go-0.6.62\out\src\debugAdapter\goDebug.js:668:45)
    at GoDebugSession.DebugSession.dispatchRequest (C:\Users\doc\.vscode\extensions\lukehoban.go-0.6.62\node_modules\vscode-debugadapter\lib\debugSession.js:430:22)
    at GoDebugSession.ProtocolServer._handleData (C:\Users\doc\.vscode\extensions\lukehoban.go-0.6.62\node_modules\vscode-debugadapter\lib\protocol.js:104:38)
    at Socket.<anonymous> (C:\Users\doc\.vscode\extensions\lukehoban.go-0.6.62\node_modules\vscode-debugadapter\lib\protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at Pipe.onread (net.js:551:20)

VSCode Version 1.13.1
Go plugin by lukehoban 0.6.62
Go 1.8.3 windows/amd64
Windows 10 x64

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jul 15, 2017

You must be having a debug configuration in your launch.json file where the program attribute is pointing to a directory.

Change that to ${file} or the path to the file you want to run and you shouldn't see this issue.

"Start without debugging" attempts to run go run on whatever is provided in the program attribute. As you know go run only takes file names. Which is why the above workaround works.

Now, if the program attribute points to a directory instead, the extension should fall back to debug mode which it clearly didn't and this is a bug.

Am currently out at a conference, will look into the bug in fallback once I get back.

Until then please use the workaround mentioned above.

Thanks for reporting!

@ramya-rao-a
Copy link
Contributor

Until I get back, if anyone wants to take a look at this issue, then read https://github.com/Microsoft/vscode-go/blob/master/src/debugAdapter/Readme.md first.

My guess is that the IntiializeEvent is never sent back from the launchRequest due to https://github.com/Microsoft/vscode-go/blob/0.6.62/src/debugAdapter/goDebug.ts#L447

@realityexists
Copy link
Author

That workaround works - thanks a lot!

@ramya-rao-a
Copy link
Contributor

This fix for this issue is now out in the latest update (0.6.63) to the Go extension

@lansman
Copy link

lansman commented Jul 28, 2017

Still have the issue even on 0.6.63 (didnt use workaround)

image

@ramya-rao-a
Copy link
Contributor

@lansman Can you share your debug configuration?

@lansman
Copy link

lansman commented Jul 29, 2017

The problem persists with or without launch.json

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jul 31, 2017

Ah! sorry @lansman. I only saw the repro steps of @realityexists and fixed the issue pertaining there.

Your issue is more about running programs that are interactive.

@roblourens When something is typed in the debug console after running Start without debugging, the evaluateRequest gets fired. Is that a bug? If not, then we can look into routing what was typed in the debug console to the process that was run using go run at https://github.com/Microsoft/vscode-go/blob/0.6.63/src/debugAdapter/goDebug.ts#L234

@realityexists
Copy link
Author

I can confirm my original issue is fixed in 0.6.63 - thanks!

@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.
Projects
None yet
Development

No branches or pull requests

3 participants