From 2e5ca1cc1fc1616d0b3575ed8a50cde8f9dbf35d Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 28 Dec 2017 13:55:13 +0100 Subject: [PATCH] Fix issue when atomic_store is called with atomic_load and there was locks. the lock taking of atomic_load was performed within the lock of atomic_store, performing a dead lock. Fix this by perfoming an evaluation of val before setting it in atomic_store. --- m-atomic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/m-atomic.h b/m-atomic.h index c7d4f1c7..4db174d0 100644 --- a/m-atomic.h +++ b/m-atomic.h @@ -225,7 +225,8 @@ static inline long long atomic_fetch_unlock (m_mutex_t *lock, long long val) if ( sizeof ((ptr)->__val) <= ATOMICI_MIN_RW_SIZE) { \ (ptr)->__val = (val); \ } else { \ - atomic_store_lock(ptr, val); \ + long long _offset = (val) - (ptr)->__zero; \ + atomic_store_lock(ptr, (ptr)->__zero + _offset); \ } \ } while (0)