fix(file-locksmith): isolate handle enumeration - #50217
fix(file-locksmith): isolate handle enumeration#50217Clint Rutkas (crutkas) wants to merge 2 commits into
Conversation
Run blockable native handle enumeration in a disposable CLI worker with a finite timeout, explicit UI errors, and cleanup coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use BOM-free UTF-8 for the worker protocol and bind workers to a kill-on-close job so parent exit cannot orphan a blocked enumeration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event. Please ensure the following before merging:
|
🧭 PR intakeVisual evidence: Required — The pull request changes product UI files, so reviewers need to see the visible result. Visual evidence is currently missing. Author actionClint Rutkas (@crutkas), please update the following before review:
See the contribution guide for the full checklist. If there is no author response within 7 days, this PR will be automatically closed. Automated PR intake; PowerToys maintainers make final decisions. |
Summary of the Pull Request
Fixes File Locksmith UI access violations and hangs by moving blockable native handle enumeration into a disposable
FileLocksmithCLI.exeworker process. The UI communicates through BOM-free UTF-8 JSON over redirected stdin/stdout, enforces a 30-second timeout, and surfaces timeout or worker failures explicitly instead of showing “No results.”This supersedes the incomplete mitigation in draft PR #49502 and addresses the crash scenarios reported in #45158 and #47200. It is intentionally separate from the File Locksmith context-menu
HANG_QUIESCElifecycle work and does not modify that code.PR Checklist
Detailed Description of the Pull Request / Additional comments
TerminateThreadrecovery fromsrc/modules/FileLocksmith/FileLocksmithLibInterop/NtdllExtensions.cpp.FileLocksmithCLI.exe --worker-jsonmode. Selected paths are sent in UTF-8 JSON over stdin, never command-line arguments or logs; results return as JSON over stdout.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSEjob, terminates the worker process tree on timeout/cancellation, and waits for cleanup. Elevation restart cancels and awaits the active query before exiting.src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithXAML/Views/MainPage.xamlandStrings/en-us/Resources.resw.UNICODE_STRINGandOpenProcessnull guards. It does not use the fourGrantedAccessheuristics from [File Locksmith] Fix Interop access-violation crashes from TerminateThread hang recovery #49502 because those masks are incomplete and would introduce false-negative lock detection.doc/devdocs/modules/filelocksmith.md.Known risk: A legitimate full-system scan taking longer than 30 seconds now fails explicitly and can be retried rather than hanging indefinitely. The exact kernel-level
NtQueryObjecthang is not deterministic in automation, so timeout cleanup is validated with a real blocked child process.Validation Steps Performed
src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csprojbuild: passed; this also builds theFileLocksmithCLIdependency.src/modules/FileLocksmith/Tests/FileLocksmithUI.UnitTests/FileLocksmithUI.UnitTests.csproj: 6/6 passed, covering success, timeout, malformed output, failed worker exit, no-orphan timeout cleanup, BOM-free Unicode-path communication with the real CLI worker, and kill-on-close job cleanup.src/modules/FileLocksmith/FileLocksmithCLI/tests/FileLocksmithCLIUnitTests.vcxprojviavstest.console.exe: 6/6 passed.FileLocksmithCLI.exe --worker-jsonstdin/stdout smoke query: exit code 0 with valid JSON; malformed worker request: exit code 2./p:SpectreMitigation=falseonly because this host lacks the Spectre-mitigated MSVC libraries. No production build setting was changed.