From 9e688dca0494cc0510b38bc6a81196593991a688 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 3 Oct 2019 17:59:06 +0200 Subject: [PATCH] =?UTF-8?q?src:=20fix=20BaseObject=20Detach=20for=20GC?= =?UTF-8?q?=E2=80=99ed=20objects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a crash in test/sequential/test-performance-eventloopdelay.js. This should be squashed into > src: introduce custom smart pointers for `BaseObject`s PR-URL: https://github.com/nodejs/quic/pull/149 Reviewed-By: James M Snell --- src/base_object-inl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base_object-inl.h b/src/base_object-inl.h index af0a7d707b..f35cd6734e 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -187,7 +187,7 @@ void BaseObject::decrease_refcount() { if (new_refcount == 0) { if (metadata->is_detached) { delete this; - } else if (metadata->wants_weak_jsobj) { + } else if (metadata->wants_weak_jsobj && !persistent_handle_.IsEmpty()) { MakeWeak(); } } @@ -195,7 +195,7 @@ void BaseObject::decrease_refcount() { void BaseObject::increase_refcount() { unsigned int prev_refcount = pointer_data()->strong_ptr_count++; - if (prev_refcount == 0) + if (prev_refcount == 0 && !persistent_handle_.IsEmpty()) persistent_handle_.ClearWeak(); }