-
Notifications
You must be signed in to change notification settings - Fork 236
Fixes #155 - selecting outermost scope crashes debug host. #156
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
Fixes #155 - selecting outermost scope crashes debug host. #156
Conversation
Because we use AddScript, that adds another scope not associated with any filename. That resulted in a StackFrame ScriptPath with a null value. Later, VSCode sent us a request for soruce with a sourceReference value of null. That caused the JSON deserialization of that message to throw and that crashed the debug host. I made two changes. First, when we construct the StackFrameDetails, if the PowerShell CallStackFrame.ScriptName is null, we use the string "<No File>" instead for ScriptPath. The second change was to ExecuteScriptAtPath. Essentially, if you do not pass args we now use AddCommand(scriptPath) which does not add the extra stack frame. If you do use args then we still use AddScript. You will see the extra outermost stack frame of "<ScriptBlock>, <NoFile>". What is somewhat useful about this is that you can open Script variables to look at $MyInvocation.Line to see how the script was invoked with the args.
Looks great! Had to restart the CI build because of a test hang :/ You can merge it anytime though. |
The test hang is an old recurring one, not to imply that your change caused it ;) |
Argh, another hang. Bad luck on Appveyor today! |
So if I debug that test ServiceExecutesReplCommandAndReceivesInputPrompt it passes. If I just run it, it fails. A timing thing? |
Yeah, there's a funky timing issue with that one for some reason... There's some kind of bug in OutputDebouncer but I haven't been able to find a consistent repro to help diagnose a fix. Only appears on AppVeyor for me. Strange thing is that I put a hack in that test to avoid it and it still seems to get hit for you. |
In my case, the extra newline is appearing between |
Does this printf (action breakpoint) output tell you anything:
|
Awesome! I was just about to do something like that, thanks for the log. I'll analyze this for a bit and let you know. After some thought, I think this is a bug in the OutputReader that I'm using to read buffered output. I can see where there might be a cause that an empty string is being returned when no output is ready yet. Your log should help me come up with the reason why |
The last line in this sequence seems wrong to me:
I think the logic for lineHasNewLine is incorrectly marking the last item as a newline when the final segment is an empty string. Let me see if I can come up with a fix |
And I think this is only when the lines that are read are being enqueued into the buffer. |
I think I have a fix for this, will submit as a separate PR |
Lets see if this fixes it: #158 |
Hmm, is this hanging again? The unit tests did all pass before I pushed the merged changes from PR #158. |
Damn... Hanging on the same test. This is really annoying. |
The unfortunate thing is that there's no reliable way to debug these issues on the CI server. The best I can usually do is enable RDP and then remote desktop into the machine and try to read the logs. I'll take a look at it some more tomorrow. You can go ahead and merge the PR if you like or you can keep it open so we can try any new bug fixes that I figure out. |
FWIW unit tests pass much more consistently now on my dev PC. Occasionally the tests hang and when I attach the debugger, I see that Shutdown is waiting for output to flush on one thread:
|
Jeez, even with a CPU load generator I can't make these issues repro on my machine. Seems like I need to specify a timeout there at the very least, but I need to check and see why it would be hanging anyway. Might be that the client's stream has disconnected before the final flush can occur so the SendEvent method in OutputDebouncer.OnFlush can't complete. That should throw an error, though... If you're able to reproduce that issue locally again sometime today, could you email me a dump of the host process? It'd be helpful to see what state everything is in at that point. |
Thanks to the dump you sent I was able to reproduce and fix the latest hang issue. Sync, merge, and try again if you don't mind :) |
Yay! The tests passed with no hangs! |
…ackframe Fixes #155 - selecting outermost scope crashes debug host.
That's awesome. Thanks a lot for the debugging help! |
No problem. Hopefully that's the end of the unit test hangs (crossing my fingers). :-) |
Haha, I'm sure I'll find a way to create some more soon ;) |
Because we use AddScript, that adds another scope not associated with any filename. That resulted in a StackFrame ScriptPath with a null value. Later, VSCode sent us a request for soruce with a sourceReference value of null. That caused the JSON deserialization of that message to throw and that crashed the debug host. I made two changes. First, when we construct the StackFrameDetails, if the PowerShell CallStackFrame.ScriptName is null, we use the string "" instead for ScriptPath. The second change was to ExecuteScriptAtPath. Essentially, if you do not pass args we now use AddCommand(scriptPath) which does not add the extra stack frame. If you do use args then we still use AddScript. You will see the extra outermost stack frame of ", ". What is somewhat useful about this is that you can open Script variables to look at $MyInvocation.Line to see how the script was invoked with the args.