From f0675d1a6fd58bbeb8e55ef4422db2fde4c8180e Mon Sep 17 00:00:00 2001 From: Ilya Alimov Date: Wed, 10 Sep 2025 18:49:20 +0300 Subject: [PATCH] hotfix tsan warning in verifier and taskmanager Issue: #ICXEXX - improved memory orders to what it should be Signed-off-by: Ilya Alimov --- .../taskmanager/utils/sp_sc_lock_free_queue.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/static_core/libpandabase/taskmanager/utils/sp_sc_lock_free_queue.h b/static_core/libpandabase/taskmanager/utils/sp_sc_lock_free_queue.h index 2431d03ef7..d0fc86fe11 100644 --- a/static_core/libpandabase/taskmanager/utils/sp_sc_lock_free_queue.h +++ b/static_core/libpandabase/taskmanager/utils/sp_sc_lock_free_queue.h @@ -199,13 +199,15 @@ public: { static_assert(ALLOCATION_TYPE == QueueElemAllocationType::INPLACE); auto inode = static_cast(node); - TSAN_ANNOTATE_IGNORE_WRITES_BEGIN(); - // Atomic with relaxed order reason: gets correct value - auto count = inode->toDeleteCount.fetch_sub(1, std::memory_order_relaxed); + + // There is atomic because the queue is used by multiple consumers using mutex, but this function is executed concurrently + // Atomic with release order reason: we need to sychronize an unprotected access to the node content with deletion of the node + auto count = inode->toDeleteCount.fetch_sub(1, std::memory_order_release); if (count == 1) { + // Atomic with acquire order reason: need to synchronize the last fetch_sub with other fetch_sub's (see above) + inode->toDeleteCount.load(std::memory_order_acquire); DeleteQueueBigNode(inode); } - TSAN_ANNOTATE_IGNORE_WRITES_END(); } private: -- Gitee