Fix a module-loading regression that caused an infinite loop#6843
Merged
daxian-dbw merged 3 commits intoPowerShell:masterfrom May 10, 2018
Merged
Fix a module-loading regression that caused an infinite loop#6843daxian-dbw merged 3 commits intoPowerShell:masterfrom
daxian-dbw merged 3 commits intoPowerShell:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Fix #6813
This regression was introduced by #6523, in
PSModuleInfo.cs. A circular nested module check was removed because the comment there suggested it happens only with a deprecated workflow module. This causes aStackOverflowexception when running into circular nested modules.Circular nested modules could happen for a module that is not well structured. For example, the module folder
testcontains two files:test.psd1andtest.psm1, andtest.psd1has the following content:The same value
testis put in both RootModule and NestedModule, which will end up with a module whose nested module points to itself.There are two changes in this PR:
PSModuleInfo.cs.Dbg.AssertinModuleCmdletBase.csand two checks before it.Dbg.Assert(newManifestInfo.SessionState == ss, when facing the example above, the nested module will first be loaded with a different session state, and then when trying to load the root module, the same loaded nested module will be reused for it. So 'newManifestInfo.SessionState' is notss. The assersion will fail in that case.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests