Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2022-08-23 15:37:59


On 09/08/2022 23:35, vl01--- via Boost-users wrote:
> Hello List,
>
> I'm using the boost::interprocess::message_queue in a project and to
> verify everything is working I created a test case. In that test case
> I'm sending and receiving data via threads.
>
> The test passes on Linux, Windows with no sanitizer and also with
> AddressSanitizer and ThreadSanitizer. I recently added Apple Silicon
> (M1) to the test matrix and now the test run with ThreadSanitizer
> enabled fails.
>
> Is boost::interprocess::message_queue thread-safe?
> Can the reported TSan error be an false-positive?
> If it that case, what test can I run to verify that?
>
> I looked at code of atomic_cas32() and it uses the legacy built-in
> __sync_val_compare_and_swap().
> Can it be that that built-in isn't supported on ARM?
> Is there a newer built-in which should be used?

It could be. Can you test if __atomic_compare_exchange avoids the TSAN
error?

inline boost::uint32_t atomic_cas32
    ( volatile boost::uint32_t *mem
    , boost::uint32_t with, boost::uint32_t cmp)
{
    __atomic_compare_exchange
      (const_cast<boost::uint32_t*>(mem), &cmp, &with, false
      ,__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
    return cmp;
}

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net