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

ArgumentOutOfRangeException when finding references crashes language/debug server #1004

Closed
bonneycm opened this issue Aug 23, 2017 · 3 comments
Labels
Issue-Bug A bug to squash.

Comments

@bonneycm
Copy link

System Details

  • Operating system name and version: Windows Server 2008 R2
  • VS Code version: 1.14.2 (also fails on 1.15)
  • PowerShell extension version: 1.4.1
  • Output from $PSVersionTable:
    PSVersion 5.0.10586.117
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.10586.117
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:
1.14.2
cb82febafda0c8c199b9201ad274e25d9a76874e
ms-vscode.PowerShell@1.4.1

Name                           Value                                                                                                                                                      
----                           -----                                                                                                                                                      
PSVersion                      5.0.10586.117                                                                                                                                              
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                    
BuildVersion                   10.0.10586.117                                                                                                                                             
CLRVersion                     4.0.30319.42000                                                                                                                                            
WSManStackVersion              3.0                                                                                                                                                        
PSRemotingProtocolVersion      2.3                                                                                                                                                        
SerializationVersion           1.1.0.1 

code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable

Issue Description

I am experiencing a problem with debugging a somewhat complex (1200+ lines) powershell script that has been running for years. I updated VS Code to 1.15 and it began to terminate in the debugger with the message "Debugger process has terminated unexpectedly." I uninstalled VS Code and reinstalled the 1.14 version, but the error persists. The script runs without error in the powershell ISE. I do not see this failure with simple a powershell script.

Attached Logs

Follow the instructions in the README

VSCodeLogs.zip

about capturing and sending logs.

@daviwil
Copy link
Contributor

daviwil commented Aug 23, 2017

Thanks for the report! Seems that the issue here is unrelated to debugging, there's an unusual crash while the language server is searching for references of a symbol:

8/23/2017 1:59:30 PM [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: Value is not between 1 and 2
    Parameter name: lineNumber
    Actual value was 258.
       at Microsoft.PowerShell.EditorServices.Utility.Validate.IsWithinRange(String parameterName, Int32 valueToCheck, Int32 lowerLimit, Int32 upperLimit)
       at Microsoft.PowerShell.EditorServices.ScriptFile.GetLine(Int32 lineNumber)
       at Microsoft.PowerShell.EditorServices.LanguageService.<>c__DisplayClass18_0.<FindReferencesOfSymbol>b__0(SymbolReference reference)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
       at Microsoft.PowerShell.EditorServices.LanguageService.<FindReferencesOfSymbol>d__18.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.CodeLenses.ReferencesCodeLensProvider.<ResolveCodeLensAsync>d__4.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.CodeLenses.CodeLensFeature.<HandleCodeLensResolveRequest>d__6.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.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 System.Threading.Tasks.Task.Execute()
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Value is not between 1 and 2
    Parameter name: lineNumber
    Actual value was 258.
       at Microsoft.PowerShell.EditorServices.Utility.Validate.IsWithinRange(String parameterName, Int32 valueToCheck, Int32 lowerLimit, Int32 upperLimit)
       at Microsoft.PowerShell.EditorServices.ScriptFile.GetLine(Int32 lineNumber)
       at Microsoft.PowerShell.EditorServices.LanguageService.<>c__DisplayClass18_0.<FindReferencesOfSymbol>b__0(SymbolReference reference)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
       at Microsoft.PowerShell.EditorServices.LanguageService.<FindReferencesOfSymbol>d__18.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.CodeLenses.ReferencesCodeLensProvider.<ResolveCodeLensAsync>d__4.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.CodeLenses.CodeLensFeature.<HandleCodeLensResolveRequest>d__6.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.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 System.Threading.Tasks.Task.Execute()<---

This exception definitely shouldn't crash the language server. We'll get it fixed in an upcoming release.

@daviwil daviwil added this to the 1.5.0 milestone Aug 23, 2017
@bonneycm
Copy link
Author

bonneycm commented Aug 23, 2017 via email

@caparkaya
Copy link

Hello,

I'm having the same problem with FindReferencesOfSymbol() function. As soon as I call it from editor context menu OR I activate CodeLens feature, integrated console crashes in one specific scenario at least. I can reproduce it every time I connect to a remote PS session and use PSEdit to edit a remote PS1 file. It also occured once for a PS1 file I opened in the local session from a network share (though it's not easily reproducible this way).

Kind Regards,

@daviwil daviwil changed the title Debugger process has terminated unexpectedly with VS Code 1.15 ArgumentOutOfRangeException when finding references crashes language/debug server Oct 27, 2017
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants