From: Mathieu Desnoyers Date: Sun, 13 Sep 2015 15:46:04 +0000 (-0400) Subject: Detect RCU read-side overflows X-Git-Tag: v0.9.0~40 X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=6ef5ddc9b4e136e250f3c5f292f847e6849e6200 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 --- 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); }