-
Notifications
You must be signed in to change notification settings - Fork 382
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
Work around runspacepool deadlock #1316
Work around runspacepool deadlock #1316
Conversation
else | ||
|
||
// Compares parameter list and mandatory parameter list. | ||
foreach (CommandElementAst commandElementAst in cmdAst.CommandElements.OfType<CommandParameterAst>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth noting that the mandatory parameter logic here is pretty flawed (I haven't changed it from the original). It takes a list of all the mandatory parameters of the cmdlet and checks to see that at least one was supplied.
But:
- There could be a parameter set specified by a provided non-mandatory parameter which has no mandatory parameters
- There could be multiple mandatory parameters in a given parameter set
Parameter binding is hard and rather than trying to fix the logic here, any attempt to fix it should be more general-purpose. But nobody seems to have complained about this yet, so I doubt it's actually a huge issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's something I'd like to fix in an external library and reuse in PSSA, PSES and a few other places
Is it possible to have a simpler test case with a less complex file (either instead or additionally)? |
Thinking of the problem on a higher level: We've only discovered that |
Please have a look at the build, there is a compilation error when compiling against |
Bugger, can't use |
Yes it is. Ideally I'd like to address this issue and area more fully, but for now just trying to unblock.
So far this is the only good repro I've found in PSSA. Even then it's not 100%, but better than nothing.
We've seen this in PSES as well and known about it for some time. It's because PkgMgmt does some extremely unusual threaded things to generate its dynamic parameters. Given that we haven't found any other cases and that this is caused by such a strange implementation, my feeling is thst the right approach is:
|
In the meantime the PSES build could pin 1.18.0 in the call to Save-Module if you want to be able to quicker release an update to the extension before PSSA re-releases? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Just one question out of curiosity: If not re-using a runspacepool does not cause the problem (if I've read the issue correctly), would it not be simpler to just have an option on GetCommandInfoLegacy
to not re-use the runspace pool for the queried command only when the command is one of the Packagemanagement ones?
I thought about that, but:
|
@bergmeister - I see the signoff for this but I just want to be sure before I merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JamesWTruher I'm still happy with it to be merged, Rob's answer was satisfactory. I don't have any concerns.
PR Summary
Fixes #1297.
Ensures we don't access the
CommandInfo.ParameterSets
property on PackageManagement cmdlets, which can cause a deadlock for us due to the parallel invocation and they way these cmdlets implement their dynamic parameters.PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.