From e4f1a10431aece74504b33950598b2af3d976b1e Mon Sep 17 00:00:00 2001 From: asiva Date: Fri, 14 Jul 2023 01:31:38 +0000 Subject: [PATCH] [VM/Runtime] Ensure an isolate exists before calling Dart_ShutdownIsolate() Fixes https://github.com/dart-lang/sdk/issues/52892 TEST=ci Change-Id: I4f0aa64642d4ba8416ef353dfca7371adc7e6bba Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313543 Reviewed-by: Ryan Macnak Commit-Queue: Siva Annamalai --- runtime/bin/error_exit.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/bin/error_exit.cc b/runtime/bin/error_exit.cc index 14b28559807..7a69a957d52 100644 --- a/runtime/bin/error_exit.cc +++ b/runtime/bin/error_exit.cc @@ -21,7 +21,11 @@ void ErrorExit(int exit_code, const char* format, ...) { Syslog::VPrintErr(format, arguments); va_end(arguments); - Dart_ShutdownIsolate(); + // Sometimes ErrorExit is called even before we have entered an isolate. + // We need to shutdown the isolate only if one exists. + if (Dart_CurrentIsolate() != nullptr) { + Dart_ShutdownIsolate(); + } // Terminate process exit-code handler. Process::TerminateExitCodeHandler();