Skip to content

Integrated Terminal crashes due to incorrect editor position #1191

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

Closed
antikhonov opened this issue Feb 7, 2018 · 2 comments
Closed

Integrated Terminal crashes due to incorrect editor position #1191

antikhonov opened this issue Feb 7, 2018 · 2 comments
Labels

Comments

@antikhonov
Copy link

antikhonov commented Feb 7, 2018

System Details

Operating system name and version: Windows 10.0.14393

code -v
1.19.3
7c4205b5c6e52a53b81c69d2b2dc8a627abaa0ba
x64

$pseditor.EditorServicesVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
1      5      1      0

code --list-extensions --show-versions
$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14393.1944
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1944
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Environment. I have tho editors open

  1. "Launcher" file. Used to set some vars and execute the script I'm currently working on. I created a debug configuration that launches that file. It has 29 lines
  2. The script file. It has 100+ lines.

The issue itself. Sometimes when I edit the second file and then switch to the first one and start typing, the PowerShell Intergrated terminal crashes right before the IntelliSence autocomplete happens. Examining verbose log discovered the ArgumentOutOfRangeException (see below). Looks like that editor position (109:2) passed to the Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition method is taken from the previous file. Since line number is bigger than actual line count in the currently open file, the Exception is thrown.

Empirically, this looks like that for some reason editor is not able to fully switch between editors in a timely fashion or the editor position is not updated on file change, but this is just a guess.

Sometimes it happens very often forcing me to restart the terminal loosing all the prepared environment which is very frustrating on long-running scripts that use cached values during development.

It looks like issue described in #918, which is not fixed yet.

Attached Logs

Nothing uncommon in the logs, except the last exception:

07.02.2018 8:27:20 [ERROR] - Method "OnListenTaskCompleted" at line 391 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs

ProtocolEndpoint message loop terminated due to unhandled exception:

System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Position 109:2 is outside of the line range of 1 to 29.
   at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
   at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
   at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Position 109:2 is outside of the line range of 1 to 29.
   at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
   at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
   at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---

07.02.2018 8:27:20 [ERROR] - Method "ProtocolEndpoint_UnhandledException" at line 418 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs

PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.
@antikhonov antikhonov changed the title Integrated Terminal Crashes Due To Incorrect Editor Position Integrated Terminal crashes due to incorrect editor position Feb 7, 2018
@antikhonov
Copy link
Author

After some tests, I was able to find the most probable reason for such behavior: the MS anti-Meltdown patch. If it is turned off, the problem vanishes. My CPU model is Intel Core2 Quad CPU Q9500 @ 2.83GHz. Turns out that applying the MS patch for Meltdown breaks the VS code or the PowerShell extension somehow. If this is true, will it be fixed somehow in the next version?

@TylerLeonhardt
Copy link
Member

Hi @antikhonov, I think this problem should be addressed by now. I'm going to close it but please let me know if you're still seeing this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants