Repository navigation
[stable] [flutter_tools] Gracefully handle Windows Application Control and security policy execution blocks - #192254
Conversation
…urity policy execution blocks (flutter#191912) When Windows Smart App Control (SAC), Windows Defender Application Control (WDAC), or Group Policy blocks execution of Flutter binaries (such as `dartaotruntime.exe` during frontend_server compilation), Dart's Win32 process runner raises a `ProcessException` with Win32 error code 4551 (`ERROR_APPLICATION_CONTROL_POLICY_BLOCK`), 1260 (`ERROR_ACCESS_DISABLED_BY_POLICY`), or 454 (`ERROR_SYSTEM_INTEGRITY_POLICY_VIOLATION`). Previously, `_handleWindowsException` did not recognize these error codes and returned `null`, which resulted in an unhandled `ProcessException` crash report (accounting for 354 crashes in Flutter 3.47.1). This PR catches these security and application control policy error codes in `_handleWindowsException` and surfaces a clean, actionable `ToolExit` instructing users to check their Windows Security Smart App Control, WDAC, or Group Policy settings and configure an exclusion for the Flutter SDK directory. Fixes flutter#191899
|
@bkonyi please fill out the PR description above, afterwards the release team will review this request. |
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request adds handling for Windows-specific security policy execution blocks (error codes 4551, 1260, and 454) in error_handling_io.dart, throwing a descriptive ToolExit message suggesting checking Windows Security settings or adding an exclusion. It also adds corresponding unit tests in error_handling_io_test.dart to verify this behavior. There are no review comments, and I have no feedback to provide.
|
@bkonyi, can you add a secondary reviewer on this PR? |
|
Done! @dcharkes, would you mind rubber stamping this? :) |
e71ed18
into
flutter:flutter-3.47-candidate.0
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
#191899
Impact Description:
When Windows Smart App Control (SAC), Windows Defender Application Control (WDAC), or Group Policy blocks execution of Flutter binaries (such as
dartaotruntime.exeexecutingfrontend_server_aot.dart.snapshot), the Flutter tool crashes with an unhandledProcessExceptioninstead of providing an actionable error message. This was the #1 tool crash in Flutter 3.47.1 (accounting for 354 crashes / 16.9% of the top 10 crashes). This fix catches the policy block error codes and displays a clearToolExitexplaining how to configure exclusions in Windows Security.Changelog Description:
[flutter/191899] When Windows Smart App Control or security policies block binary execution on Windows, gracefully handle the error with an actionable message instead of crashing.
Workaround:
Manually add an exclusion for the Flutter SDK directory in Windows Security / Smart App Control / WDAC settings, or disable Smart App Control. However, users experiencing the crash currently receive an unhandled stack trace without clear indication of why execution was blocked.
Risk:
Test Coverage:
Validation Steps:
flutter test test/general.shard/base/error_handling_io_test.dartto verify that Windows error codes 4551, 1260, and 454 are mapped to the expectedToolExitmessage.flutter buildor compile a Flutter project to verify that the tool exits cleanly with the explanatory error message rather than crashing with an unhandledProcessException.