Skip to content

Circular reference leads to stack overflow when FileSystem provider is not loaded #12734

@dkattan

Description

@dkattan

Steps to reproduce

Create

InitialSessionState iss = InitialSessionState.Create();
iss.LanguageMode = PSLanguageMode.ConstrainedLanguage;
iss.ImportPSModule("Microsoft.Powershell.Utility",  "Microsoft.PowerShell.Security");
Runspace myRunSpace = RunspaceFactory.CreateRunspace(_host, iss);
myRunSpace.Open();
PowerShell powershell = PowerShell.Create();
powershell.Runspace = myRunSpace;
powershell.AddScript("Hello World");
powershell.Invoke();

Expected behavior

Hello World

Actual behavior

TryModuleAutoDiscovery calls LookupCommandInfo which calls TryModuleAutoDiscovery which calls LookupCommandInfo forever

result = TryModuleAutoDiscovery(commandName, context, originalCommandName, commandOrigin,

result = LookupCommandInfo(commandName, commandTypes, searchResolutionOptions, commandOrigin, context);

This is where the Exception gets swallowed allowing for the infinite loop when FileSystem provider is not present:

Environment data

PowerShell 7.1.0 release 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions