From e32eddc550eb1aad8fe291a2808c22d1d6142aa5 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Sun, 15 Apr 2018 15:29:33 +0530 Subject: [PATCH] src: move v8::HandleScope call to Emit Move v8::HandleScope call to Emit removing it from previous locations where it was added to avoid crashing (constructor and destructor of AsyncWrap) for a more general and fool-proof solution. Ref: https://github.com/nodejs/node/pull/19972#issuecomment-381353894 PR-URL: https://github.com/nodejs/node/pull/20045 Reviewed-By: Yang Guo Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell Reviewed-By: Daniel Bevenius --- src/async_wrap-inl.h | 2 -- src/async_wrap.cc | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/async_wrap-inl.h b/src/async_wrap-inl.h index f9c709aa21e..c9f12333243 100644 --- a/src/async_wrap-inl.h +++ b/src/async_wrap-inl.h @@ -50,7 +50,6 @@ inline AsyncWrap::AsyncScope::AsyncScope(AsyncWrap* wrap) Environment* env = wrap->env(); if (env->async_hooks()->fields()[Environment::AsyncHooks::kBefore] == 0) return; - v8::HandleScope handle_scope(env->isolate()); EmitBefore(env, wrap->get_async_id()); } @@ -58,7 +57,6 @@ inline AsyncWrap::AsyncScope::~AsyncScope() { Environment* env = wrap_->env(); if (env->async_hooks()->fields()[Environment::AsyncHooks::kAfter] == 0) return; - v8::HandleScope handle_scope(env->isolate()); EmitAfter(env, wrap_->get_async_id()); } diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 5e0543a12d9..06dcbb4fb1d 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -169,6 +169,7 @@ void Emit(Environment* env, double async_id, AsyncHooks::Fields type, if (async_hooks->fields()[type] == 0) return; + v8::HandleScope handle_scope(env->isolate()); Local async_id_value = Number::New(env->isolate(), async_id); FatalTryCatch try_catch(env); USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));