Opened 7 years ago
Closed 7 years ago
#11362 closed Bugs (fixed)
smart_ptr spinlocks leads to livelock on ARM Cortex-A9 CPUs
Reported by: | alex | Owned by: | Peter Dimov |
---|---|---|---|
Milestone: | To Be Determined | Component: | smart_ptr |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | arm spinlock | Cc: |
Description
Spinlock used in smart_ptr for ARM architecture (smart_ptr/details/spinlock_gcc_arm.hpp) relies on swp/mcr instruction sequence or ldrex/strex/dmb depending on ARM version. Both these implementations are affected by an ARM issue described in errata 754327 for ARM Cortex-A9 CPU.
Suggested fix is to add "dmb" instruction to change spinlock::unlock() method:
void unlock() {
asm volatile( BOOST_SP_ARM_BARRIER ::: "memory" ); *const_cast< int volatile* >( &v_ ) = 0; asm volatile( BOOST_SP_ARM_BARRIER ::: "memory" );
}
Second barrier was added as recommended workaround from ARM errata document.
In https://github.com/boostorg/smart_ptr/commit/a42dda0af44727466c07e2d7fb3cfbb649b51bf2.