Skip to content

[vm/io] Reap exit-handler wakeup process - #64053

Open
bsutton wants to merge 1 commit into
dart-lang:mainfrom
bsutton:fix-exit-handler-zombie
Open

[vm/io] Reap exit-handler wakeup process#64053
bsutton wants to merge 1 commit into
dart-lang:mainfrom
bsutton:fix-exit-handler-zombie

Conversation

@bsutton

@bsutton bsutton commented Aug 14, 2026

Copy link
Copy Markdown

ExitCodeHandler::TerminateExitCodeThread() forks a short-lived child to
wake the exit-handler thread from wait(). If that thread observes
running_ == false before entering wait(), it exits without reaping the
wakeup child. In a container, that child can be adopted by a Dart process
running as PID 1 and remain as a zombie.

Retain the wakeup PID and call waitpid() after the exit-handler thread has
terminated. ECHILD is accepted because it means the handler thread already
reaped the process. Apply the equivalent change on Linux and macOS.

Add a Linux regression test that:

  • makes the test process a child subreaper;
  • invokes an activated executable through dart pub global run;
  • verifies that no zombie child is adopted after the intermediate Dart VM
    exits.

Validation:

  • Before the patch, the regression test reproduced the zombie on its first
    invocation using a source-built Dart 3.12.2 SDK.
  • Before the patch, the container harness reproduced
    dart:dartdev_aot <defunct> under container PID 1.
  • After the patch, the official standalone regression test passes.
  • After the patch, the exact fatal-dartdoc container harness completed 30
    iterations without a zombie on Dart 3.12.2 and a source build from main.
  • The focused standalone process suite passed 33 tests. The existing
    process_child_test could not create its process stream in the local
    restricted sandbox and failed independently of this change.

Fixes #61624.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:
  • See our contributor guide for general expectations for PRs.
  • Larger or significant changes should be discussed in an issue before creating a PR.
  • Contributions to our repos should follow the Dart style guide and use dart format.

Note that this repository uses Gerrit for code reviews. Your pull request will be automatically converted into a Gerrit CL and a link to the CL written into this PR. The review will happen on Gerrit but you can also push additional commits to this PR to update the code review.

@copybara-service

Copy link
Copy Markdown

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/+/536480

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).

@copybara-service

Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/536480 has been updated with the latest commits from this pull request.

@bsutton
bsutton marked this pull request as ready for review August 14, 2026 09:36
@copybara-service

Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/536480 has been updated with the latest commits from this pull request.

@copybara-service

Copy link
Copy Markdown

CL has new comments, please view and respond to them in Gerrit.

If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews.

Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zombie child processes.

1 participant