Skip to content

Commit 2d94f77

Browse files
committed
src: ensure that SetImmediate()s have HandleScopes
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]>
1 parent e8c2917 commit 2d94f77

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/env.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ void Environment::RunAndClearNativeImmediates() {
376376
auto drain_list = [&]() {
377377
v8::TryCatch try_catch(isolate());
378378
for (auto it = list.begin(); it != list.end(); ++it) {
379+
#ifdef DEBUG
380+
v8::SealHandleScope seal_handle_scope(isolate());
381+
#endif
379382
it->cb_(this, it->data_);
380383
if (it->refed_)
381384
ref_count++;

src/node_file.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ inline void FileHandle::Close() {
178178
// it is being thrown from within the SetImmediate handler and
179179
// there is no JS stack to bubble it to. In other words, tearing
180180
// down the process is the only reasonable thing we can do here.
181+
HandleScope handle_scope(env->isolate());
181182
env->ThrowUVException(detail->ret, "close", msg);
182183
delete detail;
183184
}, detail);

src/node_http2.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ void Http2Stream::EmitStatistics() {
520520
static_cast<Http2StreamPerformanceEntry*>(data) };
521521
if (!HasHttp2Observer(env))
522522
return;
523+
HandleScope handle_scope(env->isolate());
523524
AliasedBuffer<double, v8::Float64Array>& buffer =
524525
env->http2_state()->stream_stats_buffer;
525526
buffer[IDX_STREAM_STATS_ID] = entry->id();
@@ -558,6 +559,7 @@ void Http2Session::EmitStatistics() {
558559
static_cast<Http2SessionPerformanceEntry*>(data) };
559560
if (!HasHttp2Observer(env))
560561
return;
562+
HandleScope handle_scope(env->isolate());
561563
AliasedBuffer<double, v8::Float64Array>& buffer =
562564
env->http2_state()->session_stats_buffer;
563565
buffer[IDX_SESSION_STATS_TYPE] = entry->type();

0 commit comments

Comments
 (0)