Skip to content

NullReferenceException from LanguageService.GetAliases() #770

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
rkeithhill opened this issue Oct 11, 2018 · 7 comments
Closed

NullReferenceException from LanguageService.GetAliases() #770

rkeithhill opened this issue Oct 11, 2018 · 7 comments
Labels

Comments

@rkeithhill
Copy link
Contributor

Well, it's a few levels down from that but I suspect it originated from GetAliases:

2018-10-08 20:40:00.354 [NORMAL] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'StartLogging', line 150:
    PowerShell Editor Services Host v2.0.0.0 starting (pid 19308)...
    
      Host application details:
    
        Name:      Visual Studio Code Host
        ProfileId: Microsoft.VSCode
        Version:   2.0.0
        Arch:      64-bit

…

2018-10-08 20:40:05.779 [VERBOSE] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs: In method 'ExecuteCommand', line 622:
    Attempting to execute command(s):
    
        
            [System.Diagnostics.DebuggerHidden()]
            [System.Diagnostics.DebuggerStepThrough()]
            param()
            return [Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]::ReadLine(
                $Host.Runspace,
                $ExecutionContext,
                $args[0]) System.Threading.CancellationToken
    

2018-10-08 20:40:05.780 [VERBOSE] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: In method 'ResolveFilePath', line 382:
    Resolved path: c:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\module\PowerShellEditorServices\Start-EditorServices.ps1

2018-10-08 20:40:05.806 [VERBOSE] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: In method 'WriteMessage', line 61:
    Writing Event 'powerShell/executionStatusChanged'

2018-10-08 20:40:05.806 [VERBOSE] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: In method 'WriteMessage', line 61:
    Writing Event 'powerShell/executionStatusChanged'

2018-10-08 20:40:05.807 [VERBOSE] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: In method 'WriteMessage', line 61:
    Writing Event 'powerShell/executionStatusChanged'

2018-10-08 20:40:05.808 [VERBOSE] C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Utility\ThreadSynchronizationContext.cs: In method 'Post', line 64:
    Attempted to post message to synchronization context after it's already completed

2018-10-08 20:40:05.976 [ERROR] C:\projects\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. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommand[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs:line 742
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommand[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs:line 787
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommand[TResult](PSCommand psCommand, Boolean sendOutputToHost, Boolean sendErrorToHost) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs:line 424
       at Microsoft.PowerShell.EditorServices.LanguageService.GetAliases() in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Language\LanguageService.cs:line 733
       at Microsoft.PowerShell.EditorServices.LanguageService.FindReferencesOfSymbol(SymbolReference foundSymbol, ScriptFile[] referencedFiles, Workspace workspace) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Language\LanguageService.cs:line 326
       at Microsoft.PowerShell.EditorServices.CodeLenses.ReferencesCodeLensProvider.ResolveCodeLensAsync(CodeLens codeLens, CancellationToken cancellationToken) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Host\CodeLens\ReferencesCodeLensProvider.cs:line 85
       at Microsoft.PowerShell.EditorServices.CodeLenses.CodeLensFeature.HandleCodeLensResolveRequest(CodeLens codeLens, RequestContext`1 requestContext) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Host\CodeLens\CodeLensFeature.cs:line 176
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageDispatcher.cs:line 160
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs:line 379
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Utility\AsyncContext.cs:line 49
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0() in C:\projects\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.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommand[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs:line 742
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommand[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs:line 787
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommand[TResult](PSCommand psCommand, Boolean sendOutputToHost, Boolean sendErrorToHost) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs:line 424
       at Microsoft.PowerShell.EditorServices.LanguageService.GetAliases() in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Language\LanguageService.cs:line 733
       at Microsoft.PowerShell.EditorServices.LanguageService.FindReferencesOfSymbol(SymbolReference foundSymbol, ScriptFile[] referencedFiles, Workspace workspace) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Language\LanguageService.cs:line 326
       at Microsoft.PowerShell.EditorServices.CodeLenses.ReferencesCodeLensProvider.ResolveCodeLensAsync(CodeLens codeLens, CancellationToken cancellationToken) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Host\CodeLens\ReferencesCodeLensProvider.cs:line 85
       at Microsoft.PowerShell.EditorServices.CodeLenses.CodeLensFeature.HandleCodeLensResolveRequest(CodeLens codeLens, RequestContext`1 requestContext) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Host\CodeLens\CodeLensFeature.cs:line 176
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageDispatcher.cs:line 160
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs:line 379
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger) in C:\projects\PowerShellEditorServices\src\PowerShellEditorServices\Utility\AsyncContext.cs:line 49
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0() in C:\projects\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)<---

BTW it would be nice if we could get the full version (including the prerelease suffix) in the log file.

@rkeithhill rkeithhill changed the title NullReferenceException from LanguageServices.GetAliases NullReferenceException from LanguageService.GetAliases Oct 11, 2018
@rkeithhill rkeithhill changed the title NullReferenceException from LanguageService.GetAliases NullReferenceException from LanguageService.GetAliases() Oct 11, 2018
@rjmholt rjmholt self-assigned this Oct 11, 2018
@rjmholt
Copy link
Contributor

rjmholt commented Oct 12, 2018

This looks like an AliasInfo object returned from invokeCommand.GetCommands("*", CommandTypes.Alias, true) was null...

Do you have a small repro scenario @rkeithhill?

@rjmholt
Copy link
Contributor

rjmholt commented Oct 12, 2018

Hmmm, actually I think the above is wrong. I'm still trying to make sense of this stack trace -- it doesn't look like PowerShellContext.ExecuteCommand() is called directly from LanguageService.GetAliases().

Just saw this is v2.

@rjmholt
Copy link
Contributor

rjmholt commented Oct 12, 2018

@rkeithhill By full version, do you mean the appveyor release suffix? I'm not quite sure how we'd get that in... Maybe we can set it as an env var, pass it into the csproj and find a way to embed it as a compile-time constant?

@rjmholt
Copy link
Contributor

rjmholt commented Oct 15, 2018

@SeeminglyScience thinks this is the same issue: #759

@rjmholt rjmholt removed their assignment Oct 16, 2018
@rkeithhill
Copy link
Contributor Author

Do you have a small repro scenario @rkeithhill?

Unfortunately, no.

@andyleejordan
Copy link
Member

Hey I'm going to close this four year old bug since GetAliases got rewritten.

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