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
Environment. I have tho editors open
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 https://github.com/PowerShell/vscode-powershell/issues/918, which is not fixed yet.
Nothing uncommon in the logs, except the last exception:
07.02.2018 8:27:20 [ERROR] - Method "OnListenTaskCompleted" at line 391 of C:\projects\powershelleditorservicessrc\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\powershelleditorservicessrc\PowerShellEditorServices.Host\EditorServicesHost.cs
PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.
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?
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!