Skip to content

Call dart::bin::Platform::Initialize during Dart VM startup#182689

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
jason-simmons:bug_182436
Feb 25, 2026
Merged

Call dart::bin::Platform::Initialize during Dart VM startup#182689
auto-submit[bot] merged 2 commits into
flutter:masterfrom
jason-simmons:bug_182436

Conversation

@jason-simmons

Copy link
Copy Markdown
Member

This does platform-specific setup for Dart (such as configuring signal handlers)

Fixes #182436
See dart-lang/sdk#62679
See dart-lang/sdk#62680

@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Feb 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces platform-specific initialization for the Dart VM during startup, specifically configuring signal handlers. This change addresses a known issue related to process handling in Dart. A new test file process_test.dart has been added to cover the Process.start functionality with a missing executable, ensuring robustness. The BUILD.gn file has been updated to include this new test. The changes align with the Flutter style guide's emphasis on testing and correctness.

Comment on lines +299 to +301
if (!dart::bin::Platform::Initialize(false)) {
FML_LOG(FATAL) << "Dart platform-specific initialization failed";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The dart::bin::Platform::Initialize(false) call is crucial for platform-specific setup, such as signal handlers, addressing the issue mentioned in the PR description. The FML_LOG(FATAL) ensures that if this critical initialization fails, the application terminates gracefully with an informative message.

"platform_isolate_test.dart",
"platform_isolate_shutdown_test.dart",
"plugin_utilities_test.dart",
"process_test.dart",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding process_test.dart to the tests list in BUILD.gn is correct and ensures the new test is included in the build process. This adheres to the repository's style guide regarding testing (Repository Style Guide, line 11).

References
  1. Code should be tested and follow the guidance described in the writing effective tests guide and the running and writing tests guide. (link)

Comment on lines +11 to +14
test('start process with missing executable', () async {
Future<Process> proc = Process.start('nonexistent-executable', []);
expect(() async => await proc, throwsA(isA<ProcessException>()));
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test effectively verifies the behavior of Process.start when attempting to execute a nonexistent program, correctly expecting a ProcessException. This is a good edge case test and improves the robustness of the Dart VM's process handling. This aligns with the repository's emphasis on writing effective tests (Repository Style Guide, line 11).

References
  1. Code should be tested and follow the guidance described in the writing effective tests guide and the running and writing tests guide. (link)

This does platform-specific setup for Dart (such as configuring signal handlers)

Fixes flutter#182436
See dart-lang/sdk#62679
See dart-lang/sdk#62680

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks jason

@jason-simmons jason-simmons added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 25, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Feb 25, 2026
Merged via the queue into flutter:master with commit 7490539 Feb 25, 2026
184 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 25, 2026
@zanderso

Copy link
Copy Markdown
Member

DBC

It looks like there could be some fighting and/or disagreement between how Flutter sets up signal handlers and how Dart does. In particular on Windows compare these two areas:

Not guarded !IsDebuggerPresent():
https://github.com/dart-lang/sdk/blob/main/runtime/bin/platform_win.cc#L51

Guarded by !IsDebuggerPresent():

_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);

Didn't look into any differences on the other platforms, but wanted to raise the flag that there are potentially behavior changes here that don't have good test coverage.

@loic-sharma

Copy link
Copy Markdown
Member

cc @mattkae @knopp in case you have any concerns with the Windows changes above: #182689 (comment)

ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
…182689)

This does platform-specific setup for Dart (such as configuring signal
handlers)

Fixes flutter#182436
See dart-lang/sdk#62679
See dart-lang/sdk#62680
knopp added a commit to knopp/flutter_zero that referenced this pull request Feb 27, 2026
Also includes:

Call dart::bin::Platform::Initialize during Dart VM startup
(flutter/flutter#182689)
xxxOVALxxx pushed a commit to xxxOVALxxx/flutter that referenced this pull request Mar 10, 2026
…182689)

This does platform-specific setup for Dart (such as configuring signal
handlers)

Fixes flutter#182436
See dart-lang/sdk#62679
See dart-lang/sdk#62680
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…182689)

This does platform-specific setup for Dart (such as configuring signal
handlers)

Fixes flutter#182436
See dart-lang/sdk#62679
See dart-lang/sdk#62680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Process.start of non existent command triggers a later OS SIGPIPE crash on MacOS

4 participants