-
Notifications
You must be signed in to change notification settings - Fork 223
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
Dead lock when getting dynamic parameters for Install-Package
while PSRL is running
#762
Comments
This is a bit more complicated than I initially expected. Series of events
Gathered points of interest |
Tagging @daxian-dbw, @PaulHigin, @BrucePay and @lzybkr, since we are in need of some expertise of PowerShell's threaded behaviour. Essentially our usage of PSReadLine is resulting in a deadlock with the PackageManagement cmdlets inside PowerShell, and we're not entirely sure how to get around it. I've read over the possibly related PowerShell/PowerShell#4003, but ultimately we need this to work in Windows PowerShell as well. We'd be very appreciative of any advice you can offer. I'm sure we can give proper explanations of PSES' implementation wherever needed (good exercise for us anyway). |
If PSReadLine is running, the PowerShell engine is "busy" because the function In the early PSReadLine days, folks noticed their OnIdle events weren't processed until after PSReadLine finished. This is currently broken in 2.0, see PowerShell/PSReadLine#773. I don't know when this regressed (no regression tests for this unfortunately), but the VSCode/PSReadLine is a likely candidate to have caused the regression. I'd start with fixing PowerShell/PSReadLine#773 and maybe this deadlock will be fixed. |
@lzybkr The I believe the problem is that |
OK, I hadn't looked at the |
PackageManagement indeed is using async and dynamics a lot. GetDynamicParameters is called here: https://github.com/OneGet/oneget/blob/173df840e345d0a753dd0a9dec684e394f1b22ea/src/Microsoft.PowerShell.PackageManagement/Cmdlets/CmdletWithProvider.cs#L426 But we have not heard deadlock from other users though. |
@jianyunt Yeah it's not a particularly common scenario so I'm not surprised it hasn't come up. Here's an easy way to reproduce it outside of VSCode: $splat = @{
SourceIdentifer = [System.Management.Automation.PSEngineEvent]::OnIdle
Action = { (Get-Command Install-Package).Parameters }
}
Register-EngineEvent @splat If you run that the prompt will become unresponsive. I've fixed the issue by saving |
👍 |
This has since been solved in a few ways on both ends (we don't use the onidle engine event, and oneget is fixed). Closing. |
I've been looking at what PowerShell says is running every time I've hit a dead lock. Every time, it's
Install-Package
generating dynamic parameters.Repro
Install module
ImpliedReflection
(or other preferred reflection module)Wait for a dead lock after completion
Get the process ID of the integrated console with
Get-PSHostProcess
(Hint: it won't have a window title)Enter the process with
Enter-PSHostProcess
Get the main PSIC runspace with
$rs = Get-Runspace 2
Enable implied reflection with
Enable-ImpliedReflection
Navigate to
$rs.ExecutionContext.CurrentCommandProcessor
. Should look something like this:Click to expand output
Navigate to
$rs.ExecutionContext.CurrentCommandProcessor.Command
. Should look something like this:Click to expand output
PackageManagement makes heavy use of async in their cmdlets. My guess is they are inheriting our single threaded background synchronization context when they previously were not.
Note: Cancelling the command via their internal API (
$rs.ExecutionContext.CurrentCommandProcessor.Command.Cancel()
) doesn't do anything, which makes sense if it's a threading related dead lock.The text was updated successfully, but these errors were encountered: