Skip to content

References CodeLens is causing a crash due to range exception #887

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
johlju opened this issue Jun 15, 2017 · 6 comments
Closed

References CodeLens is causing a crash due to range exception #887

johlju opened this issue Jun 15, 2017 · 6 comments
Labels
Area-Pester Issue-Bug A bug to squash.

Comments

@johlju
Copy link

johlju commented Jun 15, 2017

System Details

  • Operating system name and version: Windows 10
PS> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      15063  0
  • VS Code version: 1.13.1
  • PowerShell extension version: 1.3.2
  • Output from $PSVersionTable: See below

$pseditor.EditorServicesVersion does not work since PowerShell Integrated Terminal i crashing.

PS > code -v
1.13.1
379d2efb5539b09112c793d3d9a413017d736f89
PS > $pseditor.EditorServicesVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
1      3      2      0
PS > code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.413
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.413
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
able

Issue Description

PowerShell Integration Terminal is crashing, and it seems when it tries to list the references. The lines shows, but the reference link does not popup, instead it crashes.

image

Attached Logs

logs.zip

@daviwil
Copy link
Contributor

daviwil commented Jun 15, 2017

Ouch! That's a weird one, sorry about that! Does it only happen in this one file?

@daviwil daviwil added this to the June 2017 milestone Jun 15, 2017
@daviwil daviwil added Area-Pester Issue-Bug A bug to squash. labels Jun 15, 2017
@daviwil daviwil changed the title PowerShell Integration Terminal is crashing every time References CodeLens is causing a crash due to range exception Jun 15, 2017
@johlju
Copy link
Author

johlju commented Jun 15, 2017

No worries :) I don't know if it's only this file, only one I worked in today, I will code in others tomorrow, so I will let you know.

@daviwil daviwil modified the milestones: June 2017, 1.4.0 Jun 16, 2017
@johlju
Copy link
Author

johlju commented Jun 16, 2017

@daviwil daviwil modified the milestones: 1.4.1, 1.4.0 Jun 21, 2017
@daviwil
Copy link
Contributor

daviwil commented Jun 21, 2017

Thanks for the details! I ran out of time to fix this for today's upcoming release but after that's done I'm going to fix this for a patch update for next week :)

@BenCamareno
Copy link

I'm having the same problem with all my modules.
References seem to start loading then PowerShell exits.

This happens in both VSCode and VSCode Insiders.

What's the setting to disable references in the User Settings?
I love that option but would like to disable it until it's fixed. :)

`[9:9:54] Language server starting...
powershell.exe started --
pid: 9844
exe: C:\windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe
args: C:\Users\xxxxxx.vscode\extensions\ms-vscode.powershell-1.4.1\scripts\Start-EditorServices.ps1 -EditorServicesVersion '1.4.1'
-HostName 'Visual Studio Code Host'
-HostProfileId 'Microsoft.VSCode'
-HostVersion '1.4.1'
-AdditionalModules @('PowerShellEditorServices.VSCode')
-BundledModulesPath 'C:\Users\xxxxxx.vscode\extensions\ms-vscode.powershell-1.4.1\modules' -EnableConsoleRepl -LogLevel 'Verbose'
-SessionDetailsPath 'C:\Users\xxxxxx.vscode\extensions\ms-vscode.powershell-1.4.1\sessions\PSES-VSCode-12084-901752'
-FeatureFlags @()

[9:10:2] Language server started.
{"debugServicePort":23359,"status":"started","channel":"tcp","languageServicePort":14975}
Connecting to language service on port 14975...

Language service connected.

powershell.exe terminated or terminal UI was closed`

@daviwil daviwil modified the milestones: 1.4.2, 1.5.0 Aug 24, 2017
@daviwil daviwil modified the milestones: 1.5.0, Future Oct 26, 2017
@rjmholt
Copy link
Contributor

rjmholt commented Apr 3, 2019

Not sure if this is still an issue. There's a good chance the code has changed a fair amount.

The error is here:

2017-06-15 18:36:19 [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 301
    Parameter name: lineNumber
    Actual value was 302.
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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 301
    Parameter name: lineNumber
    Actual value was 302.
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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.ExceptionServices.ExceptionDispatchInfo.Throw()
       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()<---

The actual crash would be a validation error now: https://github.com/PowerShell/PowerShellEditorServices/blob/8c66fa912ecfac4e93345ca96dc49d1787f81f1d/src/PowerShellEditorServices/Workspace/ScriptFile.cs#L254-L266

We've done some work on this. There is an outstanding bug, but I don't think it's quite this one. Here: #1561.

Going to close this, since I suspect this is fixed.

@rjmholt rjmholt closed this as completed Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Pester Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

4 participants