-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix deadlock when piping to shell associated file extension #19940
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 deadlock when piping to shell associated file extension #19940
Conversation
If the initial process creation failed and `shell32!FindExecutableW` was used, the process initialization flag was getting skipped. Moving the handle release until after the try/catch fixed a hang.
Search |
src/System.Management.Automation/engine/NativeCommandProcessor.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/NativeCommandProcessor.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/NativeCommandProcessor.cs
Outdated
Show resolved
Hide resolved
This reverts commit 4052701.
Must have some automatic formatting set that I'm not aware of. Didn't mean for these changes to be added.
Hmm does that work outside of CI? I wasn't able to get Thanks I'll look into it |
Also remove redundant lock
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
So even if |
| { | ||
| _processInitialized ??= new SemaphoreSlim(0, 1); | ||
| _processInitialized.Release(); | ||
| } |
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.
btw I removed the lock because we're already in a lock for that object and I just didn't notice (line 596)
Interesting.... if it is possible to reproduce the issue with Python can we emulate the same behavior with cmd.exe and .bat and use this in tests? |
The main issue is that in recent history it's been made explicitly unsupported to set shell associations outside of the UI. I've heard of some ways, but it involves reverse engineered formats that change between Windows versions? Something like that, but either way not something we'd want to use in a test. |
daxian-dbw
left a comment
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.
LGTM
|
Hi, do you know if there is going to be a preview and/or release build with this fix any time soon? |
Fixes #19876
PR Summary
Marking the process as initialized was done inside a
trythat can be part of normal operation ifshell32!FindExecutableWfinds a valid console subsystem executable. This change moves it after the try so that scenario will be caught as well.Also reduced some allocations inIsExecutable. That change is separated into it's own commit for easier review, but I'm also fine with reverting that commit if desired.I don't think there's an non-interactive way to set a file extension these days so I'm not sure how this could be tested. If you know of a way (that doesn't use undocumented APIs) please comment.
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).