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
Cyclic rescursion with a Symbolic link in a PSModulePath will hang the creation of ModuleAnalysisCache & hang TabCompletion #10667
Comments
I guess the issue is for native command discovery too. Also completers can have another code paths to process PSModulePath. User's code also can be affected. Default PSModulePath has not broken links and only user himself can add suck links. So it looks like an edge case and I'd do not fix anything as "won't fix". |
We could add Depth check in the file enumeration. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
2 similar comments
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Reopening as this I think still needs reviewed whether or not this is still an issue, I'd do more investigation into this if personal circumstances weren't a current blocker for me to be able to do so properly |
This issue was diagnosed in the PowerShell Slack off of the back of this message from @TheMusicMeister
Whilst this issue was found on Windows in PowerShell v5.1.18362.145, I've tested and confirmed this is still an issue in v5.1.18990.1, v6.2.3 & v7.0.0.preview.4 & we have managed to track down the issue to being an issue with there being a case of cyclic recursion on trying to find all modules in a PSModulePath due to a Symbolic Link being nested within one of the paths in
PSModulePath
and it pointing to a directory nested within one of the paths listed in the PSModulePathSteps to reproduce
This is a simplified reproduction but achieves the same issues as reported.
Create a symbolic link at
C:\Tools\Modules\Subpath\
that links toC:\Tools\Modules
& then addC:\Tools\
as a path in the PSModulePathOnce created remove your Module Analysis Cache (simple rename works) then run
Get-Module -ListAvailable -All -Refresh
to completely recreate the cache, optionally runningTrace-Command -PSHost -Name Modules -Expression { Get-Module -ListAvailable -All -Refresh }
to see progress of the recreation of the Module Analysis CacheEventually (with enough folders to traverse thorough) this will hang the console which has the
Expected behavior
PowerShell ideally should intelligently realise that it's in a directory that contains a symbolic link that links to a parent directory that is already contained in the PSModulePath and skip it entirely. However to do so would require changes to the current behaviour and this is a relatively niche error that I wouldn't expect to see all that often.
Actual behavior
PowerShell will consume memory whilst trying to recursively search all entries in the PSModulePath and will then eventually throw the below error in (v6.2.3 & v.7.0.0.preview4 unsure on v5.1)
**
**
Environment data
v7.0.0.preview.4
v6.2.3
v5.1.18990.1
v5.1.18362.145
Windows 10
The text was updated successfully, but these errors were encountered: