From 1dc1b015ebc09404f2a6d76a3034f22fe21b7d6d Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 8 Apr 2026 08:33:32 -0700 Subject: [PATCH] [dart:io, win] Don't delete the process list mutex during shutdown. The exit callback might fire during or after dart:io shutdown. TEST=ci (flaky) Bug: https://github.com/dart-lang/sdk/issues/60499 Change-Id: I950ef4a6ba1d99a8eafb55cb051a60f0cb097e71 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493485 Reviewed-by: Alexander Aprelev Commit-Queue: Ryan Macnak --- runtime/bin/process_win.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc index 54193bc005a..0e7b6965c00 100644 --- a/runtime/bin/process_win.cc +++ b/runtime/bin/process_win.cc @@ -159,7 +159,9 @@ class ProcessInfoList { HANDLE exit_pipe; bool success = LookupProcess(pid, &handle, &wait_handle, &exit_pipe); if (!success) { - FATAL("Failed to lookup process in list of active processes"); + // Failed to lookup process in list of active processes. This might happen + // if a child exits after dart:io shutdown. + return; } // Unregister the event in a non-blocking way. BOOL ok = UnregisterWait(wait_handle); @@ -1333,15 +1335,14 @@ void Process::ClearSignalHandlerByFd(intptr_t fd, Dart_Port port) { } void ProcessInfoList::Init() { - active_processes_ = nullptr; - ASSERT(ProcessInfoList::mutex_ == nullptr); - ProcessInfoList::mutex_ = new Mutex(); + if (mutex_ == nullptr) { + mutex_ = new Mutex(); + } } void ProcessInfoList::Cleanup() { - ASSERT(ProcessInfoList::mutex_ != nullptr); - delete ProcessInfoList::mutex_; - ProcessInfoList::mutex_ = nullptr; + // Do not delete mutex_. A child process might exit during/after dart:io + // shutdown. } void Process::Init() {