[vm] Allow to skip crash handler installation in bin::Platform::Initialize.#62680
[vm] Allow to skip crash handler installation in bin::Platform::Initialize.#62680Arbaaz123676 wants to merge 2 commits into
Conversation
|
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/480880 Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR). |
|
There is already code in |
|
Hi @mraleph, Thanks for the pointer! That makes sense — I added the masking here because I observed SIGPIPE during the exit pipe write path on macOS, but if Platform::Initialize already configures it, then something later must be modifying the mask. I’ll investigate where SIGPIPE handling may be reset after initialization. Do you have a recommended area to check (Flutter embedder vs VM runtime), or should I go with tracing signal mask changes around process start? Happy to adjust the approach based on the intended design. |
|
See my comment here: #62679 (comment) |
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
| if (sigaction(SIGILL, &act, nullptr) != 0) { | ||
| perror("sigaction() failed."); | ||
| return false; | ||
| if (install_crash_handler){ |
There was a problem hiding this comment.
Not properly formatted: missing space here.
In general, I'd recommend running git cl format to make sure that all code is properly formatted.
| int message[2] = {exit_code, negative}; | ||
| ssize_t result = | ||
| FDUtils::WriteToBlocking(exit_code_fd, &message, sizeof(message)); | ||
| ssize_t result = |
There was a problem hiding this comment.
Fully revert changes to this file as they are not necessary.
|
The title of this PR should probably be updated to match what we are doing here. |
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
1145ba9 to
e77016d
Compare
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
mraleph
left a comment
There was a problem hiding this comment.
A better name for the PR is: [vm] Allow to skip crash handler installation in bin::Platform::Initialize
| } | ||
|
|
||
| bool Platform::Initialize() { | ||
| bool Platform::Initialize(bool install_crash_handler) { |
There was a problem hiding this comment.
-
We would usually write
bool install_crash_hander /* = true */to make default value obvious (otherwise reader must go to declaration to see it). -
You need to modify all platform specific
Platform::Initializeimplementations in allruntime/bin/platform_*.ccfiles in the same way. Otherwise the build will break.
There was a problem hiding this comment.
Just to confirm before I proceed — since we changed the signature of Platform::Initialize in platform.h, do you want me to update the function signature to Initialize(bool install_crash_handler /*= true */) across all platform-specific implementations (platform_linux.cc, platform_win.cc, platform_fuchsia.cc, platform.cc) as well, without changing their logic?
There was a problem hiding this comment.
Not changing the logic would be inconsistent. They should all do the same thing, so they should all get the additional parameter and respect that parameter.
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
e77016d to
5efabee
Compare
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
| } | ||
|
|
||
| bool Platform::Initialize() { | ||
| bool Platform::Initialize(bool install_crash_handler /* = true */) { |
There was a problem hiding this comment.
This should be the same as Mac OS X version, but it is not updated for some reason and just ignores the parameter.
|
|
||
| bool Platform::Initialize() { | ||
| bool Platform::Initialize(bool install_crash_handler /* = true */) { | ||
| PlatformWin::InitOnce(); |
There was a problem hiding this comment.
PlatformWin::InitOnce installs crash handler. So it should probably respect install_crash_handler.
5efabee to
b79fda3
Compare
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
There was a problem hiding this comment.
I think we want to if (install_crash_handler) just this one. Not other things in this function.
b79fda3 to
deeed63
Compare
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/480880 has been updated with the latest commits from this pull request. |
|
@mraleph, Updated macOS, Linux and Windows implementations to consistently respect "install_crash_handler". Only crash handler setup is conditional now. Please let me know if anything else needs adjustment. |
|
I have merged the CL. Thanks for the contribution. Now we need to figure what to do with Flutter embedder. It should just call |
|
What if we add a call to |
|
Yeah, something like that. You should ask Flutter engine folks what's the best place to put it in. |
|
Thanks! I’m not very familiar yet with the Flutter engine workflow — should I open an issue in the Flutter engine repo about where to place the |
|
@Arbaaz123676 you can start by asking on Flutter Discord. |
|
Hello @mraleph — one of the Flutter contributors replied with: Calling I’m not sure whether any OS-specific Based on this, I’m planning to open an issue in the Flutter repository (https://github.com/flutter/flutter/issues) also with reference of the related Dart issue (#62679) as well as the PR (#62680) for context. I would really appreciate your guidance on whether this is the right place to track it and if there’s anything specific I should consider before opening the issue. Thank you! |
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
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
This does platform-specific setup for Dart (such as configuring signal handlers) Fixes #182436 See dart-lang/sdk#62679 See dart-lang/sdk#62680
…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
…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
…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
Summary
On macOS, writing to a closed exit pipe can deliver SIGPIPE which terminates the process even when EPIPE is handled correctly.
This change temporarily blocks SIGPIPE while writing the exit code in "ExitCodeHandlerEntry". This ensures that failed "Process.start" calls do not trigger unintended process termination.
The signal mask is scoped only around the write operation to keep the behaviour localized and avoid affecting global signal handling.
Platform: macOS only
Fixes: #62679.