Skip to content

Commit

Permalink
src: ensure that SetImmediate()s have HandleScopes
Browse files Browse the repository at this point in the history
Make sure that all native `SetImmediate()` functions have
`HandleScope`s if they create handles.

PR-URL: #19470
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
addaleax committed Mar 25, 2018
1 parent e8c2917 commit 2d94f77
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ void Environment::RunAndClearNativeImmediates() {
auto drain_list = [&]() {
v8::TryCatch try_catch(isolate());
for (auto it = list.begin(); it != list.end(); ++it) {
#ifdef DEBUG
v8::SealHandleScope seal_handle_scope(isolate());
#endif
it->cb_(this, it->data_);
if (it->refed_)
ref_count++;
Expand Down
1 change: 1 addition & 0 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ inline void FileHandle::Close() {
// it is being thrown from within the SetImmediate handler and
// there is no JS stack to bubble it to. In other words, tearing
// down the process is the only reasonable thing we can do here.
HandleScope handle_scope(env->isolate());
env->ThrowUVException(detail->ret, "close", msg);
delete detail;
}, detail);
Expand Down
2 changes: 2 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ void Http2Stream::EmitStatistics() {
static_cast<Http2StreamPerformanceEntry*>(data) };
if (!HasHttp2Observer(env))
return;
HandleScope handle_scope(env->isolate());
AliasedBuffer<double, v8::Float64Array>& buffer =
env->http2_state()->stream_stats_buffer;
buffer[IDX_STREAM_STATS_ID] = entry->id();
Expand Down Expand Up @@ -558,6 +559,7 @@ void Http2Session::EmitStatistics() {
static_cast<Http2SessionPerformanceEntry*>(data) };
if (!HasHttp2Observer(env))
return;
HandleScope handle_scope(env->isolate());
AliasedBuffer<double, v8::Float64Array>& buffer =
env->http2_state()->session_stats_buffer;
buffer[IDX_SESSION_STATS_TYPE] = entry->type();
Expand Down

0 comments on commit 2d94f77

Please sign in to comment.