diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc index 08a427cf2fd..c5e7b2eff02 100644 --- a/runtime/bin/gen_snapshot.cc +++ b/runtime/bin/gen_snapshot.cc @@ -316,8 +316,11 @@ PRINTF_ATTRIBUTE(1, 2) static void PrintErrAndExit(const char* format, ...) { Syslog::VPrintErr(format, args); va_end(args); - Dart_ExitScope(); - Dart_ShutdownIsolate(); + // ExitScope and ShutdownIsolate will abort() if there is no current isolate. + if (Dart_CurrentIsolate() != nullptr) { + Dart_ExitScope(); + Dart_ShutdownIsolate(); + } exit(kErrorExitCode); }