From 6eacee5e13577342a72f310d0560581bb26f3be3 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Mon, 19 Sep 2022 17:09:09 +0200 Subject: [PATCH] Fixup2 --- src/env.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/env.cc b/src/env.cc index c3994705f8fa74..d8c80736229b91 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1048,11 +1048,14 @@ void Environment::RunAndClearInterrupts() { void Environment::RunAndClearNativeImmediates(bool only_refed) { TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "RunAndClearNativeImmediates"); - if (isolate_->IsExecutionTerminating()) - return; HandleScope handle_scope(isolate_); - InternalCallbackScope cb_scope(this, Object::New(isolate_), { 0, 0 }); + // In case the Isolate is no longer accessible just use an empty Local. This + // is not an issue for InternalCallbackScope as this case is already handled + // in its constructor but we avoid calls into v8 which can crash the process + // in debug builds. + Local obj = can_call_into_js() ? Object::New(isolate_) : Local(); + InternalCallbackScope cb_scope(this, obj, { 0, 0 }); size_t ref_count = 0;