From 6ef5ddc9b4e136e250f3c5f292f847e6849e6200 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 13 Sep 2015 11:46:04 -0400 Subject: [PATCH] Detect RCU read-side overflows Use the urcu_assert() macro (enabled on DEBUG_RCU) to check for unmatched rcu_read_lock() that eventually leads to nesting counter overflow in urcu.h and urcu-bp.h. This won't necessarily point the the exact rcu_read_lock() that is unmatched, but will at least detect the overflow condition. Signed-off-by: Mathieu Desnoyers --- urcu/static/urcu-bp.h | 1 + urcu/static/urcu.h | 1 + 2 files changed, 2 insertions(+) diff --git a/urcu/static/urcu-bp.h b/urcu/static/urcu-bp.h index ffd4b89..df25393 100644 --- a/urcu/static/urcu-bp.h +++ b/urcu/static/urcu-bp.h @@ -154,6 +154,7 @@ static inline void _rcu_read_lock(void) rcu_bp_register(); /* If not yet registered. */ cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ tmp = URCU_TLS(rcu_reader)->ctr; + urcu_assert((tmp & RCU_GP_CTR_NEST_MASK) != RCU_GP_CTR_NEST_MASK); _rcu_read_lock_update(tmp); } diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h index c44c137..3fb457b 100644 --- a/urcu/static/urcu.h +++ b/urcu/static/urcu.h @@ -224,6 +224,7 @@ static inline void _rcu_read_lock(void) urcu_assert(URCU_TLS(rcu_reader).registered); cmm_barrier(); tmp = URCU_TLS(rcu_reader).ctr; + urcu_assert((tmp & RCU_GP_CTR_NEST_MASK) != RCU_GP_CTR_NEST_MASK); _rcu_read_lock_update(tmp); } -- 2.34.1