[ Service ] Fix issue where VM would hang in ServiceIsolate::Shutdown if

shutdown immediately after starting up

Running the VM with arguments that cause a quick failure _after_ the
service isolate is started could result in the VM service starting and
attempting to register a signal handler after the VM has started
shutting down. The open port held by the signal handler prevented the
message handler from shutting down, resulting in the main thread being
blocked on a monitor in ServiceIsolate::Shutdown.

Could be reproduced with the following commands:

$ rm out/DebugX64/dartdev.dart.snapshot
$ out/DebugX64/dart --observe hello_world.dart

Change-Id: I70ddff73c98151bd7eff22064a23f897b4d6299f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156923
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2020-08-03 23:24:42 +00:00 committed by commit-bot@chromium.org
parent 7bb0d1f39a
commit d3945b56f7

View file

@ -222,6 +222,12 @@ _onSignal(ProcessSignal signal) {
Timer? _registerSignalHandlerTimer;
_registerSignalHandler() {
if (VMService().isExiting) {
// If the VM started shutting down we don't want to register this signal
// handler, otherwise we'll cause the VM to hang after killing the service
// isolate.
return;
}
_registerSignalHandlerTimer = null;
if (_signalWatch == null) {
// Cannot register for signals.