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

Crash when deleting lines #739

Closed
rjmholt opened this issue Sep 4, 2018 · 3 comments
Closed

Crash when deleting lines #739

rjmholt opened this issue Sep 4, 2018 · 3 comments
Assignees
Labels

Comments

@rjmholt
Copy link
Contributor

rjmholt commented Sep 4, 2018

Deleted multiple empty lines from the end of a file in vim-mode and got this crash:

2018-09-04 11:40:41.973 [ERROR] /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs: In method 'OnListenTaskCompleted', line 391:
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index) ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices/Workspace/ScriptFile.cs:line 399
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs:line 555
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs:line 110
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs:line 142
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs:line 379
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices/Utility/AsyncContext.cs:line 49
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0() in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices/Utility/AsyncContextThread.cs:line 66
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices/Workspace/ScriptFile.cs:line 399
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs:line 555
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs:line 110
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs:line 142
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs:line 379
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger) in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices/Utility/AsyncContext.cs:line 49
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0() in /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices/Utility/AsyncContextThread.cs:line 66
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
    

2018-09-04 11:40:41.973 [ERROR] /home/rob/Documents/Dev/Microsoft/PowerShellEditorServices/src/PowerShellEditorServices.Host/EditorServicesHost.cs: In method 'ProtocolEndpoint_UnhandledException', line 435:
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.
@rjmholt
Copy link
Contributor Author

rjmholt commented Sep 5, 2018

Hit this again today:

2018-09-05 15:11:41.106 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: In method 'OnListenTaskCompleted', line 391:
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index) ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       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(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       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(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
    

@rkeithhill
Copy link
Contributor

This looks eerily familiar. I think this was the type of error I had tried to fix in the ValidatePosition code. Feels like we might have a "whack a mole" bug here. :-)

@rjmholt
Copy link
Contributor Author

rjmholt commented Sep 13, 2018

I was afraid of that -- I thought I'd handled it cleverly by only allowing a +1 offset and then testing for that specific case, but I think I haven't quite done it right...

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

3 participants