Skip to content

Commit

Permalink
src: move v8::HandleScope call to Emit
Browse files Browse the repository at this point in the history
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: #19972 (comment)

PR-URL: #20045
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information
ryzokuken committed Apr 20, 2018
1 parent 76f5b39 commit e32eddc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions src/async_wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ 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());
}

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());
}

Expand Down
1 change: 1 addition & 0 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value> 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));
Expand Down

0 comments on commit e32eddc

Please sign in to comment.