Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 1af3703

Browse files
committed
src: fix closing weak HandleWraps on GC
In 0af62aa, this was overlooked, with it possibly leading to hard crashes. Refs: nodejs/node#29317 PR-URL: nodejs/node#29640 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent f787f88 commit 1af3703

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/handle_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ void HandleWrap::Close(Local<Value> close_callback) {
7272
if (state_ != kInitialized)
7373
return;
7474

75-
CHECK_EQ(false, persistent().IsEmpty());
7675
uv_close(handle_, OnClose);
7776
state_ = kClosing;
7877

79-
if (!close_callback.IsEmpty() && close_callback->IsFunction()) {
78+
if (!close_callback.IsEmpty() && close_callback->IsFunction() &&
79+
!persistent().IsEmpty()) {
8080
object()->Set(env()->context(),
8181
env()->handle_onclose_symbol(),
8282
close_callback).Check();

test/sequential/test-performance-eventloopdelay.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --expose-gc
12
'use strict';
23

34
const common = require('../common');
@@ -97,3 +98,7 @@ const {
9798
}
9899
spinAWhile();
99100
}
101+
102+
// Make sure that the histogram instances can be garbage-collected without
103+
// and not just implictly destroyed when the Environment is torn down.
104+
process.on('exit', global.gc);

0 commit comments

Comments
 (0)