Skip to content

Stack Overflows in Specific File #4809

@functionkey-12

Description

@functionkey-12

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

While in a specific Workspace, my PowerShell Extension experiences a stack overflow. This occurs while I am typing in the editor. It has happened after typing 1 character in the active file. If I restart the extension, and only work in the console, it does not crash.

The workspaces settings file is just a directory location, and the cwd for the extension. I have remove the values from these keys and the issue persists.

PowerShell Version

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.8
PSEdition                      Core
GitCommitId                    7.3.8
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

PS 7.3.8> code --version
1.83.1
f1b07bd25dfad64b0167beb15359ae573aecd2cc
x64

Extension Version

PS 7.3.8> code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2023.8.0

Steps to Reproduce

I restarted the extension and in the editor window, I start typing. Sometimes I am able to type out a line, sometimes I am only able to type "$".

Visuals

Moments before this screenshot I restarted the extension, and typed the single "$" in the if statement. I have removed any configuration from the workspace file.
image

Logs

I have attempted to capture the output to the terminal, as shown in the screenshot. This text is quickly cleared as the extension halts. There maybe more output, but I am unsure.

PS 7.3.8> Stack overflow.
Repeat 2413 times:
--------------------------------
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.MemberExpressionAst)
   at System.Management.Automation.TypeInferenceVisitor.AddInferredTypesForDollarUnderbar(System.Management.Automation.Language.Ast, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.InferTypeFrom(System.Management.Automation.Language.VariableExpressionAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitVariableExpression(System.Management.Automation.Language.VariableExpressionAst)
   at System.Management.Automation.TypeInferenceVisitor.GetExpressionType(System.Management.Automation.Language.ExpressionAst, Boolean)
--------------------------------
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.MemberExpressionAst)
   at System.Management.Automation.TypeInferenceVisitor.AddInferredTypesForDollarUnderbar(System.Management.Automation.Language.Ast, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.InferTypeFrom(System.Management.Automation.Language.VariableExpressionAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitVariableExpression(System.Management.Automation.Language.VariableExpressionAst)
   at System.Management.Automation.TypeInferenceVisitor.<InferTypesFromSelectCommand>g__InferFromSelectProperties|65_0(System.Management.Automation.Language.AstParameterArgumentPair, System.Management.Automation.Language.CommandBaseAst, 
Boolean, <>c__DisplayClass65_0 ByRef)
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFromSelectCommand(System.Management.Automation.Language.PseudoBindingInfo, System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFromObjectCmdlets(System.Management.Automation.Language.CommandAst, System.Management.Automation.CmdletInfo, System.Management.Automation.Language.PseudoBindingInfo)      
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitCommand(System.Management.Automation.Language.CommandAst)
   at System.Management.Automation.TypeInferenceVisitor.InferTypeFrom(System.Management.Automation.Language.VariableExpressionAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitVariableExpression(System.Management.Automation.Language.VariableExpressionAst)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitStatementBlock(System.Management.Automation.Language.StatementBlockAst)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitIfStatement(System.Management.Automation.Language.IfStatementAst)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitStatementBlock(System.Management.Automation.Language.StatementBlockAst)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitSwitchStatement(System.Management.Automation.Language.SwitchStatementAst)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitNamedBlock(System.Management.Automation.Language.NamedBlockAst)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitScriptBlock(System.Management.Automation.Language.ScriptBlockAst)
   at System.Management.Automation.TypeInferenceVisitor.GetInferredTypeFromScriptBlockParameter(System.Management.Automation.Language.AstParameterArgumentPair, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)  
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFromForeachCommand(System.Management.Automation.Language.PseudoBindingInfo, System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFromObjectCmdlets(System.Management.Automation.Language.CommandAst, System.Management.Automation.CmdletInfo, System.Management.Automation.Language.PseudoBindingInfo)      
   at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
   at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitCommand(System.Management.Automation.Language.CommandAst)
   at System.Management.Automation.AstTypeInference.InferTypeOf(System.Management.Automation.Language.Ast, System.Management.Automation.TypeInferenceContext, System.Management.Automation.TypeInferenceRuntimePermissions)
   at System.Management.Automation.CompletionCompleters.CompleteVariable(System.Management.Automation.CompletionContext)
   at System.Management.Automation.CompletionAnalysis.GetResultForIdentifier(System.Management.Automation.CompletionContext, Int32 ByRef, Int32 ByRef, Boolean)
   at System.Management.Automation.CompletionAnalysis.GetResultHelper(System.Management.Automation.CompletionContext, Int32 ByRef, Int32 ByRef, Boolean)
   at System.Management.Automation.CompletionAnalysis.GetResults(System.Management.Automation.PowerShell, Int32 ByRef, Int32 ByRef)
   at System.Management.Automation.CommandCompletion.CompleteInputImpl(System.Management.Automation.Language.Ast, System.Management.Automation.Language.Token[], System.Management.Automation.Language.IScriptPosition, System.Collections.Hashtable)
   at DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Type, System.Management.Automation.Language.Ast, System.Management.Automation.Language.Token[], System.Object, System.Collections.Hashtable)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute5[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Runtime.CompilerServices.CallSite, System.__Canon, System.__Canon, System.__Canon, System.__Canon, System.__Canon)
   at System.Management.Automation.Interpreter.DynamicInstruction`6[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon)
   at System.Management.Automation.PSScriptCmdlet.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
   at System.Management.Automation.CommandProcessorBase.Complete()
   at System.Management.Automation.CommandProcessorBase.DoComplete()
   at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object)
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
   at System.Management.Automation.Runspaces.LocalPipeline.StartPipelineExecution()
   at System.Management.Automation.Runspaces.PipelineBase.CoreInvoke(System.Collections.IEnumerable, Boolean)
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(System.Collections.IEnumerable)
   at System.Management.Automation.PowerShell+Worker.ConstructPipelineAndDoWork(System.Management.Automation.Runspaces.Runspace, Boolean)
   at System.Management.Automation.PowerShell+Worker.CreateRunspaceIfNeededAndDoWork(System.Management.Automation.Runspaces.Runspace, Boolean)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Management.Automation.PSDataCollection`1<System.__Canon>, System.Management.Automation.PSDataCollection`1<System.__Canon>, System.Management.Automation.PSInvocationSettings)
   at System.Management.Automation.PowerShell.CoreInvoke[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Management.Automation.PSDataCollection`1<System.__Canon>, System.Management.Automation.PSDataCollection`1<System.__Canon>, System.Management.Automation.PSInvocationSettings)
   at System.Management.Automation.PowerShell.Invoke[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.IEnumerable, System.Management.Automation.PSInvocationSettings)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Management.Automation.PowerShell, System.Management.Automation.PSInvocationSettings)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeCommand[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Management.Automation.PowerShell, System.Management.Automation.PSCommand, System.Management.Automation.PSInvocationSettings)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteNormally(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteSynchronously(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteAndGetResult(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.Symbols.AstOperations+<>c__DisplayClass2_0.<GetCompletionsAsync>b__0(System.Management.Automation.PowerShell, System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPSDelegateTask.Run(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteSynchronously(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.ExecuteTaskSynchronously(Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.ISynchronousTask, System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.OnPowerShellIdle(System.Threading.CancellationToken)
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(System.Management.Automation.Runspaces.Runspace, System.Management.Automation.EngineIntrinsics, System.Threading.CancellationToken, System.Nullable`1<Boolean>)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.PsrlReadLine.InvokePSReadLine(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousDelegateTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteSynchronously(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteAndGetResult(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeDelegate[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String, Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.ExecutionOptions, System.Func`2<System.Threading.CancellationToken,System.__Canon>, System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.PsrlReadLine.ReadLine(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeReadLine(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(System.Threading.CancellationToken)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.RunExecutionLoop(Boolean)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.RunTopLevelExecutionLoop()
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.PushPowerShellAndMaybeRunLoop(Microsoft.PowerShell.EditorServices.Services.PowerShell.Context.PowerShellContextFrame, Boolean)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.PushPowerShellAndMaybeRunLoop(System.Management.Automation.PowerShell, Microsoft.PowerShell.EditorServices.Services.PowerShell.Context.PowerShellFrameType, Microsoft.PowerShell.EditorServices.Services.PowerShell.Runspace.RunspaceInfo, Boolean)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.PushPowerShellAndRunLoop(System.Management.Automation.PowerShell, Microsoft.PowerShell.EditorServices.Services.PowerShell.Context.PowerShellFrameType, Microsoft.PowerShell.EditorServices.Services.PowerShell.Runspace.RunspaceInfo)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.Run()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)


   

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions