diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-24 22:05:44 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-03-05 22:40:04 +0100 |
commit | 820ae61c12b12ceca23d96a30e1bbe8e601bc735 (patch) | |
tree | b6ce607bfea1261838b4d602babb06d08949a335 | |
parent | 753ebd742fc5da81c201dfc59fdc42cd80312ec3 (diff) | |
download | android-node-v8-820ae61c12b12ceca23d96a30e1bbe8e601bc735.tar.gz android-node-v8-820ae61c12b12ceca23d96a30e1bbe8e601bc735.tar.bz2 android-node-v8-820ae61c12b12ceca23d96a30e1bbe8e601bc735.zip |
src: forbid handle allocations from Platform tasks
Platform tasks should have their own handle scopes, rather than
leak into outer ones.
PR-URL: https://github.com/nodejs/node/pull/26376
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r-- | src/inspector/main_thread_interface.cc | 8 | ||||
-rw-r--r-- | src/node_platform.cc | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index c58ea4cb41..14f90fbd9d 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -268,6 +268,14 @@ void MainThreadInterface::DispatchMessages() { MessageQueue::value_type task; std::swap(dispatching_message_queue_.front(), task); dispatching_message_queue_.pop_front(); + + // TODO(addaleax): The V8 inspector code currently sometimes allocates + // handles that leak to the outside scope, rendering a HandleScope here + // necessary. This handle scope can be removed/turned into a + // SealHandleScope once/if + // https://chromium-review.googlesource.com/c/v8/v8/+/1484304 makes it + // into our copy of V8, maybe guarded with #ifdef DEBUG if we want. + v8::HandleScope handle_scope(isolate_); task->Call(this); } } while (had_messages); diff --git a/src/node_platform.cc b/src/node_platform.cc index 9b1c4b4ca9..115b59e356 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -8,11 +8,11 @@ namespace node { -using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::Object; using v8::Platform; +using v8::SealHandleScope; using v8::Task; using node::tracing::TracingController; @@ -332,7 +332,9 @@ int NodePlatform::NumberOfWorkerThreads() { void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr<Task> task) { Isolate* isolate = Isolate::GetCurrent(); - HandleScope scope(isolate); +#ifdef DEBUG + SealHandleScope scope(isolate); +#endif Environment* env = Environment::GetCurrent(isolate); if (env != nullptr) { InternalCallbackScope cb_scope(env, Local<Object>(), { 0, 0 }, |