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

Hard crash (of everything) when debugging nodejs #18758

Closed
chadbr opened this issue Jan 18, 2017 · 30 comments
Closed

Hard crash (of everything) when debugging nodejs #18758

chadbr opened this issue Jan 18, 2017 · 30 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues important Issue identified as high-priority verified Verification succeeded
Milestone

Comments

@chadbr
Copy link

chadbr commented Jan 18, 2017

  • VSCode Version: Version 1.8.1 (1.8.1) - ee428b0 - 2016-12-19T14:40:36.266Z
  • OS Version: macos 10.12.2
  • Nodejs version: v6.7.0

Steps to Reproduce:

  1. open code in empty folder
  2. create an app.js with 2 console.writeline() functions
  3. set breakpoints
  4. go to debug pane, accept default setup
  5. press f5 or debug button
  6. when breakpoint is hit, press the stop button

On my colleges machine, vscode crashes. On my machine everything crashes (the shell, all applications, everything...) then the shell restarts.

repo gif attached... you don't see the crash because the app recording the gif gets killed...
crashanim

Anyone else???

@dbaeumer dbaeumer added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jan 19, 2017
@isidorn
Copy link
Contributor

isidorn commented Jan 19, 2017

@chadbr I can not reproduce this behavior.

  1. Do you see this all the time
  2. Do you only see this when debugging Javascript or for all languages
  3. Do you also see this when you disable all extensions in vscode
  4. Do you see this with VSCode insiders also

ping @weinand for ideas

@isidorn isidorn added the info-needed Issue requires more information from poster label Jan 19, 2017
@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

@isidorn

  1. yes, every time.

for my colleague - this just started. He asked me to try to see if I had the same issues.

He rolled back to the previous version of vscode and had the same result.

I haven't debugged any node code in a while -- so I'm not sure when it started on my machine.

  1. only nodejs AFAIK. I debugged both .net core & angular2 tests very recently with no issues.

  2. I'll try this today...

  3. Same results with the insiders build.

@isidorn
Copy link
Contributor

isidorn commented Jan 19, 2017

@weinand might it be that node-debug somehow terminates vscode by accident

@chadbr since this seems to be happening for your celleague and you (nobody else complained) can you distill what do those two machines have in come. Same node version? Same os version? Something special

@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

@isidorn @weinand

Tried #3 - disabled all plugins - didn't help.

I don't have anything special going on -- typical mac dev box with 500 apps on it :)

I'm happy to let you remote in? or is there some telemetry I can enable or?

@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

could uninstalling / reinstalling potentially help? any instructions for "cleaning code" from a machine?

I hope to get this working soon - I use code all day every day!

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Cannot reproduce either.
console does not have a function writeline(), but this doesn't explain the issue you are seeing...

Please add a trace property to your launch config like this:

		{
			"type": "node",
			"request": "launch",
			"name": "Launch Program",
			"program": "${workspaceRoot}/test.js",
			"cwd": "${workspaceRoot}",
			"trace": "all"
		}

and post the resulting debug console output here.

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

What happens if you do not press the 'terminate' button but the green 'continue' (play) button instead?

@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

if I press pause it crashes - let me play with above -

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Please try our experimental node2 debugger by changing the value of the type attribute in your launch config to node2. Do you see the same behaviour?

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

More things you can try (only one at a time):

  • reboot your Mac
  • install a different version of node, e.g. 6.5
  • open the "Console" application and then watch out for any suspicious entries that appear when pressing the 'terminate' button in VS Code.

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Inside the VS Code app is a script "terminateProcess.sh" in "/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug/out/node/terminateProcess.sh"
This scripts uses the pgrep command. Do you have a different pgrep command installed on your system?
If you don't know you could rename the "terminateProcess.sh" temporarily so that VS Code will not find it any more. Does the crash still occur?

@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

@weinand wow - that fixed it --

I did this:
Chads-MacBook-Pro:Github chadbr$ mv /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug/out/node/terminateProcess.sh /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug/out/node/SAVE-terminateProcess.sh

  • here's the contents if it helps

#!/bin/bash

terminateTree() {
for cpid in $(pgrep -P $1); do
terminateTree $cpid
done
kill -9 $1 > /dev/null 2>&1
}

for pid in $*; do
terminateTree $pid
done

@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

should I try any of the others?

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

@chadbr no, it seems that you found the culprit.
Now the question is why does it behave like this on your system?
Please type which pgrep in a terminal. What is the resulting path?

@chadbr
Copy link
Author

chadbr commented Jan 19, 2017

@weinand
$ which pgrep
/usr/local/bin/pgrep

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Aha, the pgrep on my Mac lives at /usr/bin/pgrep.
So you seem to have a different version (and VS Code seems to call the wrong one which is clearly a bug on our side).

@lucas-natraj
Copy link

lucas-natraj commented Jan 19, 2017

This was happening to me (#14187) although it only killed vscode.
On clicking the 'stop' it would take ~12 seconds and then vscode would crash.
I wiped node, nvm, all node_modules, node_gyp, vscode and extensions, then restarted my machine and reinstalled everything (except the extensions).
It still takes ages to stop debugging but at least it doesn't seem to kill vscode anymore.

With the 'trace' line in the launch config the time appears to be spent at

...
shutdown: kill debugee and sub-processes
----------  *** Waits really long here *** ----------
disconnectRequest: send response
_terminated: socket end
_terminated: node v8protocol close

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

@lucas-natraj what is the path to your pgrep?

@lucas-natraj
Copy link

lucas-natraj commented Jan 19, 2017

Same as @chadbr
/usr/local/bin/pgrep

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Do you know what this /usr/local/bin/pgrep really is?

@lucas-natraj
Copy link

lucas-natraj commented Jan 19, 2017

/usr/local/bin/pgrep -> /usr/local/Cellar/proctools/0.4pre1/bin/pgrep

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Could you try to change the pgrep in the "terminateProcess.sh" in "/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug/out/node/terminateProcess.sh" to /usr/bin/pgrep and check whether this makes a difference?

@weinand weinand added bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority and removed info-needed Issue requires more information from poster labels Jan 19, 2017
@weinand weinand added this to the January 2017 milestone Jan 19, 2017
@lucas-natraj
Copy link

That seemed to fix it. Stops debugging immediately!

...Happiness...

Gratitudes!!

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

@lucas-natraj @chadbr thanks a lot for helping with the investigation!

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

I can easily reproduce the problem after running this brew install proctools

@lucas-natraj
Copy link

Good to hear.
Am curious to know why it was previously delaying and then crashing vscode, but after the reinstall only the delay remained.

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

pgrep is used to find all sub-processes launched by the debug target. For a simple node program it should not find any sub-processes.

So if I launch node and then do a ps to find its process ID (e.g. 36915) and then use /usr/bin/pgrep -P 36915 no process IDs are listed. This is the correct behaviour.

If I use the pgrep installed by brew I get a list of 456 process IDs. This doesn't seem right. So either brew's pgrep is broken or the semantics of the -Poption is different.

The "terminateProcess.sh" script then tries to kill all those processes (which takes a long time and most kills will fail due to missing permissions).

@lucas-natraj
Copy link

Cool. That explains the delay.
Was the crash occurring because of the missing kill permission? Or something else?

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

The crash of VS Code or the Finder etc. occurs because brew's pgrep returns the process IDs of many (if not all) processes and the script tries to kill them all. I really mean all macOS processes!

The -P option should filter this list to only those processes that are child processes of the specified process. But this filter doesn't work for brew's pgrep command.

@weinand
Copy link
Contributor

weinand commented Jan 19, 2017

Fixed in tomorrows Insiders build

roblourens added a commit to microsoft/vscode-node-debug2 that referenced this issue Jan 20, 2017
@roblourens roblourens added the verified Verification succeeded label Jan 27, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues important Issue identified as high-priority verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants