[Engine] Fix silent buffer mismatch bug in FML Win32 CommandLineFromPlatform#187120
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Code Review
This pull request updates command_line_win.cc to pass the correct argument length to WideCharToMultiByte instead of -1. A review comment suggests storing the result of wcslen(arg) in a local variable to avoid redundant computations and using it to prevent implicit narrowing conversion warnings, aligning with the Google C++ Style Guide.
1481f88 to
8b10c24
Compare
8b10c24 to
ce885fd
Compare
|
autosubmit label was removed for flutter/flutter/187120, because - The status or check suite Linux linux_host_engine_test has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
ce885fd to
f4abeac
Compare
…latform Resolves a critical, long-standing bug inside FML's Windows platform CommandLineFromPlatform command-line parser. On Windows, the wide-character to UTF-8 converter (WideCharToMultiByte) was being passed -1 as the cbMultiByte count, causing it to attempt to write the converted arguments plus an extra null terminator. However, the pre-allocated buffer size only had space for the non-null terminated string length (arg_len), causing the Win32 API to fail with ERROR_INSUFFICIENT_BUFFER and silently return an empty string. As a result, the command line parser would silently fail on Windows and fall back to standard narrow-character command-line arguments (argc/argv). This caused all non-ASCII (UTF-8) characters in paths (such as user names like 'Jérôme') to be permanently corrupted, subsequently crashing downstream compiled tools like impellerc (the Impeller shader compiler) with unhandled ShaderCompilerException (exit code -1073741819) during Material design shader builds. This C++ engine-level fix resolves the buffer mismatch by passing wcslen(arg) to WideCharToMultiByte, matching the pre-allocated buffer size perfectly and ensuring that all UTF-8 wide paths are correctly preserved and parsed on Windows. Fixes flutter#186955 TAG=agy CONV=aecb9c22-0b32-40b6-9bf0-51bb472c408d
f4abeac to
079e1c5
Compare
flutter/flutter@f3a4b98...c8f2f16 2026-05-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Flutter GPU] Add explicit draw counts (#186639)" (flutter/flutter#187170) 2026-05-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 7dcea971af6b to f3db7b7d9801 (2 revisions) (flutter/flutter#187144) 2026-05-27 bdero@google.com [Flutter GPU] Add explicit draw counts (flutter/flutter#186639) 2026-05-27 engine-flutter-autoroll@skia.org Roll Skia from f9db7748563e to fa944af10f91 (1 revision) (flutter/flutter#187139) 2026-05-27 bdero@google.com [Flutter GPU] Flutter GPU ShaderLibrary in-place reload for shader hot reload (flutter/flutter#186793) 2026-05-27 engine-flutter-autoroll@skia.org Roll Skia from a692cbf38952 to f9db7748563e (8 revisions) (flutter/flutter#187135) 2026-05-27 burak.karahan@mail.ru Use local semantics tester in Material button tests (flutter/flutter#186667) 2026-05-27 rmolivares@renzo-olivares.dev Filter out `a: text input` from `team-framework` PR triage (flutter/flutter#187129) 2026-05-27 bkonyi@google.com [Engine] Fix silent buffer mismatch bug in FML Win32 CommandLineFromPlatform (flutter/flutter#187120) 2026-05-27 srawlins@google.com examples: Remove unused parameters (flutter/flutter#185819) 2026-05-27 116356835+AbdeMohlbi@users.noreply.github.com Remove another `String.valueOf` (flutter/flutter#186628) 2026-05-27 alex.medinsh@gmail.com Print trace when skipping flavor-specific and platform-specific assets (flutter/flutter#187045) 2026-05-26 adilhanney@disroot.org Fix `InteractiveViewer` memory leak from undisposed `CurvedAnimation`s (flutter/flutter#185826) 2026-05-26 meylis@divine.video Fix AccessibilityBridge startup crash on vendor-modified Android (flutter/flutter#184630) 2026-05-26 keertip@users.noreply.github.com Update data driven fixes docs (flutter/flutter#186217) 2026-05-26 ahmedsameha1@gmail.com Add more 0x0 size tests part10 (flutter/flutter#186201) 2026-05-26 46920873+gabrimatic@users.noreply.github.com Disable spell check for obscured text (flutter/flutter#186329) 2026-05-26 chris@bracken.jp [iOS] Migrate VSyncClient and DisplayLinkManager to Swift (flutter/flutter#187001) 2026-05-26 bkonyi@google.com [flutter_tools, devicelab] Add safety filesystem guard to tests (flutter/flutter#186748) 2026-05-26 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Itd2Jq_ZIABH2rW7B... to k9EizfEGJO4WwQN9-... (flutter/flutter#187115) 2026-05-26 engine-flutter-autoroll@skia.org Roll Dart SDK from 00e625453c43 to 7dcea971af6b (1 revision) (flutter/flutter#187117) 2026-05-26 rmacnak@google.com Remove use of deprecated copy_trees. (flutter/flutter#187091) 2026-05-26 15619084+vashworth@users.noreply.github.com Use resolved implementation plugins with SwiftPM (flutter/flutter#187097) 2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from 27a819894f7c to a692cbf38952 (3 revisions) (flutter/flutter#187109) 2026-05-26 engine-flutter-autoroll@skia.org Roll Packages from 69cf959 to fc795e5 (4 revisions) (flutter/flutter#187114) 2026-05-26 mvincentong@gmail.com Handle simctl process exceptions during discovery (flutter/flutter#186501) 2026-05-26 mvincentong@gmail.com Clarify precache enabled platforms help (flutter/flutter#186878) 2026-05-26 bkonyi@google.com [tool] Refactor artifacts.dart to use enhanced enums and reduce duplication (flutter/flutter#187063) 2026-05-26 jason-simmons@users.noreply.github.com Build script updates for syncing engine sources and building artifacts on linux-arm64 (flutter/flutter#186917) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC boetger@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#11795) flutter/flutter@f3a4b98...c8f2f16 2026-05-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Flutter GPU] Add explicit draw counts (#186639)" (flutter/flutter#187170) 2026-05-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 7dcea971af6b to f3db7b7d9801 (2 revisions) (flutter/flutter#187144) 2026-05-27 bdero@google.com [Flutter GPU] Add explicit draw counts (flutter/flutter#186639) 2026-05-27 engine-flutter-autoroll@skia.org Roll Skia from f9db7748563e to fa944af10f91 (1 revision) (flutter/flutter#187139) 2026-05-27 bdero@google.com [Flutter GPU] Flutter GPU ShaderLibrary in-place reload for shader hot reload (flutter/flutter#186793) 2026-05-27 engine-flutter-autoroll@skia.org Roll Skia from a692cbf38952 to f9db7748563e (8 revisions) (flutter/flutter#187135) 2026-05-27 burak.karahan@mail.ru Use local semantics tester in Material button tests (flutter/flutter#186667) 2026-05-27 rmolivares@renzo-olivares.dev Filter out `a: text input` from `team-framework` PR triage (flutter/flutter#187129) 2026-05-27 bkonyi@google.com [Engine] Fix silent buffer mismatch bug in FML Win32 CommandLineFromPlatform (flutter/flutter#187120) 2026-05-27 srawlins@google.com examples: Remove unused parameters (flutter/flutter#185819) 2026-05-27 116356835+AbdeMohlbi@users.noreply.github.com Remove another `String.valueOf` (flutter/flutter#186628) 2026-05-27 alex.medinsh@gmail.com Print trace when skipping flavor-specific and platform-specific assets (flutter/flutter#187045) 2026-05-26 adilhanney@disroot.org Fix `InteractiveViewer` memory leak from undisposed `CurvedAnimation`s (flutter/flutter#185826) 2026-05-26 meylis@divine.video Fix AccessibilityBridge startup crash on vendor-modified Android (flutter/flutter#184630) 2026-05-26 keertip@users.noreply.github.com Update data driven fixes docs (flutter/flutter#186217) 2026-05-26 ahmedsameha1@gmail.com Add more 0x0 size tests part10 (flutter/flutter#186201) 2026-05-26 46920873+gabrimatic@users.noreply.github.com Disable spell check for obscured text (flutter/flutter#186329) 2026-05-26 chris@bracken.jp [iOS] Migrate VSyncClient and DisplayLinkManager to Swift (flutter/flutter#187001) 2026-05-26 bkonyi@google.com [flutter_tools, devicelab] Add safety filesystem guard to tests (flutter/flutter#186748) 2026-05-26 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Itd2Jq_ZIABH2rW7B... to k9EizfEGJO4WwQN9-... (flutter/flutter#187115) 2026-05-26 engine-flutter-autoroll@skia.org Roll Dart SDK from 00e625453c43 to 7dcea971af6b (1 revision) (flutter/flutter#187117) 2026-05-26 rmacnak@google.com Remove use of deprecated copy_trees. (flutter/flutter#187091) 2026-05-26 15619084+vashworth@users.noreply.github.com Use resolved implementation plugins with SwiftPM (flutter/flutter#187097) 2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from 27a819894f7c to a692cbf38952 (3 revisions) (flutter/flutter#187109) 2026-05-26 engine-flutter-autoroll@skia.org Roll Packages from 69cf959 to fc795e5 (4 revisions) (flutter/flutter#187114) 2026-05-26 mvincentong@gmail.com Handle simctl process exceptions during discovery (flutter/flutter#186501) 2026-05-26 mvincentong@gmail.com Clarify precache enabled platforms help (flutter/flutter#186878) 2026-05-26 bkonyi@google.com [tool] Refactor artifacts.dart to use enhanced enums and reduce duplication (flutter/flutter#187063) 2026-05-26 jason-simmons@users.noreply.github.com Build script updates for syncing engine sources and building artifacts on linux-arm64 (flutter/flutter#186917) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC boetger@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…latform (flutter#187120) ### Description This pull request resolves a critical, long-standing C++ bug inside FML's Windows platform `CommandLineFromPlatform` command-line parser that caused all wide-character UTF-8 command arguments to be silently discarded and corrupted. * **The Bug:** In `fml/platform/win/command_line_win.cc`, `WideCharToMultiByte` was being passed `-1` as the input length (cbMultiByte) inside the string conversion loop. This instructed the Win32 API to write the converted UTF-8 string *plus* an extra null terminator. However, the pre-allocated buffer size `utf8_arg` only had space for `arg_len` (which excludes the null terminator). Consequently, the Win32 API failed with `ERROR_INSUFFICIENT_BUFFER` and returned `0`, leaving the string argument completely empty or corrupted. * **The Fallback & Crash:** Due to this silent conversion failure, the FML parser always fell back to standard narrow-character command-line arguments (`argc/argv`). This caused all non-ASCII (UTF-8) characters in paths (such as usernames containing accented letters like `Jérôme` or East Asian characters) to be corrupted. Downstream compiled tools like `impellerc` (the Impeller shader compiler) received these corrupted paths and crashed with `ShaderCompilerException` (exit code `-1073741819` Access Violation / Segmentation Fault) when compiling Material Design shaders. * **The Fix:** Resolves the buffer mismatch by passing `wcslen(arg)` to the second `WideCharToMultiByte` call, matching the pre-allocated buffer size perfectly and ensuring that all UTF-8 wide paths are correctly preserved and parsed on Windows. Fixes flutter#186955
Description
This pull request resolves a critical, long-standing C++ bug inside FML's Windows platform
CommandLineFromPlatformcommand-line parser that caused all wide-character UTF-8 command arguments to be silently discarded and corrupted.fml/platform/win/command_line_win.cc,WideCharToMultiBytewas being passed-1as the input length (cbMultiByte) inside the string conversion loop. This instructed the Win32 API to write the converted UTF-8 string plus an extra null terminator. However, the pre-allocated buffer sizeutf8_argonly had space forarg_len(which excludes the null terminator). Consequently, the Win32 API failed withERROR_INSUFFICIENT_BUFFERand returned0, leaving the string argument completely empty or corrupted.argc/argv). This caused all non-ASCII (UTF-8) characters in paths (such as usernames containing accented letters likeJérômeor East Asian characters) to be corrupted. Downstream compiled tools likeimpellerc(the Impeller shader compiler) received these corrupted paths and crashed withShaderCompilerException(exit code-1073741819Access Violation / Segmentation Fault) when compiling Material Design shaders.wcslen(arg)to the secondWideCharToMultiBytecall, matching the pre-allocated buffer size perfectly and ensuring that all UTF-8 wide paths are correctly preserved and parsed on Windows.Fixes #186955