Skip to content

Commit

Permalink
src: fix closing weak HandleWraps on GC
Browse files Browse the repository at this point in the history
In 0af62aa, this was overlooked, with it
possibly leading to hard crashes.

Refs: #29317

PR-URL: #29640
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
addaleax authored and BridgeAR committed Sep 25, 2019
1 parent c718c60 commit f84f1db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handle_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ void HandleWrap::Close(Local<Value> close_callback) {
if (state_ != kInitialized)
return;

CHECK_EQ(false, persistent().IsEmpty());
uv_close(handle_, OnClose);
state_ = kClosing;

if (!close_callback.IsEmpty() && close_callback->IsFunction()) {
if (!close_callback.IsEmpty() && close_callback->IsFunction() &&
!persistent().IsEmpty()) {
object()->Set(env()->context(),
env()->handle_onclose_symbol(),
close_callback).Check();
Expand Down
5 changes: 5 additions & 0 deletions test/sequential/test-performance-eventloopdelay.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-gc
'use strict';

const common = require('../common');
Expand Down Expand Up @@ -97,3 +98,7 @@ const {
}
spinAWhile();
}

// Make sure that the histogram instances can be garbage-collected without
// and not just implictly destroyed when the Environment is torn down.
process.on('exit', global.gc);

0 comments on commit f84f1db

Please sign in to comment.