Opened 5 years ago

#13265 new Bugs

boost atomic lib memory_order error

Reported by: haisql@… Owned by: timblechmann
Milestone: To Be Determined Component: atomic
Version: Boost 1.63.0 Severity: Showstopper
Keywords: Cc:

Description

boost atomic lib memory_order error.

someone deleted memory_order_release/memory_order_acquire code, which should be translate to sfence/lfence , but now you see that they were removed.

BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT {

if (order == memory_order_seq_cst) {

asm volatile (

#if defined(x86_64)
defined(SSE2)

"mfence\n"

#else

"lock; addl $0, (%%esp)\n"

#endif

::: "memory"

);

} else if ((order & (memory_order_acquire | memory_order_release)) != 0) {

asm volatile ("" ::: "memory");

}

}

I suggest code is:

BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT {

if (order == memory_order_seq_cst) {

asm volatile (

#if defined(x86_64)
defined(SSE2)

"mfence\n"

#else

"lock; addl $0, (%%esp)\n"

#endif

::: "memory"

);

return; }

if ((order & (memory_order_acquire )!=0 ){

asm volatile (

#if defined(x86_64)
defined(SSE2)

"lfence\n"

#else

"lock; addl $0, (%%esp)\n"

#endif

::: "memory"

);

return; }

if ((order & (memory_order_release )!=0 ){

asm volatile (

#if defined(x86_64)
defined(SSE2)

"sfence\n"

#else

"lock; addl $0, (%%esp)\n"

#endif

::: "memory"

);

}

}

Linux system do not delete lfence and sfence code, but why C++ lib deleted, this will cause error in multi_thread programe.

Change History (0)

Note: See TracTickets for help on using tickets.