diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-26 17:05:25 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-28 17:49:11 +0100 |
commit | 5b59c248413af4e81a0616286790b3dc718107ef (patch) | |
tree | 5b2078e4d515638137ea21814113c4ca7a2b9634 /src | |
parent | f73716d35aa14d4808be2775dc8374db7aa2fed9 (diff) | |
download | android-node-v8-5b59c248413af4e81a0616286790b3dc718107ef.tar.gz android-node-v8-5b59c248413af4e81a0616286790b3dc718107ef.tar.bz2 android-node-v8-5b59c248413af4e81a0616286790b3dc718107ef.zip |
src: add more `can_call_into_js()` guards
This is in preparation for running native `SetImmediate()`
callbacks during shutdown.
PR-URL: https://github.com/nodejs/node/pull/30666
Fixes: https://github.com/nodejs/node/issues/30643
Refs: https://github.com/nodejs/node/pull/30374
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/env.cc | 5 | ||||
-rw-r--r-- | src/node_errors.cc | 5 | ||||
-rw-r--r-- | src/node_process_events.cc | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/env.cc b/src/env.cc index 5f9a6acb46..da253fac6d 100644 --- a/src/env.cc +++ b/src/env.cc @@ -527,6 +527,9 @@ void Environment::RegisterHandleCleanups() { } void Environment::CleanupHandles() { + Isolate::DisallowJavascriptExecutionScope disallow_js(isolate(), + Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); + for (ReqWrapBase* request : req_wrap_queue_) request->Cancel(); @@ -661,7 +664,7 @@ void Environment::RunAndClearNativeImmediates() { head->Call(this); if (UNLIKELY(try_catch.HasCaught())) { - if (!try_catch.HasTerminated()) + if (!try_catch.HasTerminated() && can_call_into_js()) errors::TriggerUncaughtException(isolate(), try_catch); // We are done with the current callback. Move one iteration along, diff --git a/src/node_errors.cc b/src/node_errors.cc index e094fe4681..17c1bd7f55 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -278,6 +278,9 @@ static void ReportFatalException(Environment* env, Local<Value> error, Local<Message> message, EnhanceFatalException enhance_stack) { + if (!env->can_call_into_js()) + enhance_stack = EnhanceFatalException::kDontEnhance; + Isolate* isolate = env->isolate(); CHECK(!error.IsEmpty()); CHECK(!message.IsEmpty()); @@ -956,7 +959,7 @@ void TriggerUncaughtException(Isolate* isolate, } MaybeLocal<Value> handled; - { + if (env->can_call_into_js()) { // We do not expect the global uncaught exception itself to throw any more // exceptions. If it does, exit the current Node.js instance. errors::TryCatchScope try_catch(env, diff --git a/src/node_process_events.cc b/src/node_process_events.cc index 440e67d412..0609622662 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -34,6 +34,8 @@ Maybe<bool> ProcessEmitWarningGeneric(Environment* env, const char* warning, const char* type, const char* code) { + if (!env->can_call_into_js()) return Just(false); + HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); |