From 4ce33b6e3b75ab9a2c46e477e8098b66681d3735 Mon Sep 17 00:00:00 2001 From: khizmax Date: Mon, 3 Oct 2016 21:55:43 +0300 Subject: [PATCH] Fixed IterableList's node reusing --- cds/intrusive/impl/iterable_list.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cds/intrusive/impl/iterable_list.h b/cds/intrusive/impl/iterable_list.h index 129104fc..6561787e 100644 --- a/cds/intrusive/impl/iterable_list.h +++ b/cds/intrusive/impl/iterable_list.h @@ -1151,7 +1151,7 @@ namespace cds { namespace intrusive { // and then set it to another. // To prevent this we mark pos.pCur data as undeletable by setting LSB marked_data_ptr val( pos.pFound ); - if ( !pos.pCur->data.compare_exchange_strong( val, val | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { + if ( pos.pCur && !pos.pCur->data.compare_exchange_strong( val, val | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { // oops, pos.pCur data has been changed or another thread is setting pos.pPrev data m_Stat.onInsertReuseFailed(); return false; @@ -1163,7 +1163,8 @@ namespace cds { namespace intrusive { memory_model::memory_order_release, atomics::memory_order_relaxed ); // Clear pos.pCur data mark - pos.pCur->data.store( val, memory_model::memory_order_relaxed ); + if ( pos.pCur ) + pos.pCur->data.store( val, memory_model::memory_order_relaxed ); if ( result ) m_Stat.onInsertReuse(); -- 2.34.1