Skip to content
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

Fix PowerShellCmdlet #4247

Merged
merged 1 commit into from Mar 7, 2024
Merged

Fix PowerShellCmdlet #4247

merged 1 commit into from Mar 7, 2024

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Mar 7, 2024

A cmdlet can use PowerShellCmdlet.ExecuteInPowerShellThread to request operations to run in the PowerShell thread and wait for it to be completed. Internally, the action gets executed and we store the exception in the ExceptionDispatchInfo member object instead of throwing it immediately. This is to preserve the stack properly and facilitate diagnostics via Get-Error.

If the cmdlet catches that exception and attempts to use the PowerShell thread again, it will end up in a deadlock because the semaphore was never released. This PR release semaphore after throwing the stored exception.

This was the case in AppxModuleHelper.AddAppxPackageAsUriAsync when Add-AppxPackage failed installing the package from a url.

Microsoft Reviewers: Open in CodeFlow

@msftrubengu msftrubengu requested a review from a team as a code owner March 7, 2024 00:28
@ryfu-msft ryfu-msft merged commit 8a00654 into microsoft:master Mar 7, 2024
8 checks passed
ryfu-msft pushed a commit to ryfu-msft/winget-cli that referenced this pull request Mar 7, 2024
ryfu-msft added a commit that referenced this pull request Mar 7, 2024
@msftrubengu msftrubengu deleted the fixcmdlet branch April 19, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants