<div dir="ltr">Hi,<div><br></div><div>Indeed, it seems that exactly this happens: "<span style="color:rgb(0,0,0);font-family:dejavusans,"dejavu sans",arial,sans-serif;font-size:12.8px">The weak forms (1-2) of the functions are allowed to fail spuriously, that is, act as if </span><span class="gmail-t-c" style="background-color:rgba(0,0,0,0.027451);border:1px solid rgb(214,214,214);border-radius:3px;margin:0px 2px;padding:0px 2px;display:inline-block;color:rgb(0,0,0);font-family:dejavusans,"dejavu sans",arial,sans-serif;font-size:12.8px"><span class="gmail-mw-geshi gmail-cpp gmail-source-cpp" style="font-family:monospace;line-height:normal;white-space:nowrap"><span class="gmail-sy2" style="color:rgb(0,0,64)">*</span>this <span class="gmail-sy3" style="color:rgb(0,0,64)">!</span><span class="gmail-sy1" style="color:rgb(0,0,128)">=</span> expected</span></span><span style="color:rgb(0,0,0);font-family:dejavusans,"dejavu sans",arial,sans-serif;font-size:12.8px"> even if they are equal.</span>" (from <a href="http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange">http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange</a> ). Because the value returned indicates that they are indeed equal. The reference doesn't say it shouldn't happen in single-threaded scenario, so I don't see a reason to investigate why this happens except curiosity... maybe the mutex is not ready, or CPU cache problem, or it translates into a single CPU instruction that fails for hardware reasons, who knows.</div><div><br></div><div>Dean, is there any reason not to change this to compare_exchange_strong() ? As I understand, polling in a loop is not an option because it's not clear for how long to iterate.</div><div><br></div><div>Cheers,</div><div>Serge</div><div><br></div><div class="gmail_extra"><div class="gmail_quote">On 25 January 2017 at 18:23, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><a class="m_-3922385260404622253GWVZpf m_-3922385260404622253gW" id="m_-3922385260404622253IloFPc-0" href="mailto:dberris@google.com" target="_blank">+Dean Michael Berris</a> <div><div class="h5"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 25, 2017 at 7:01 AM Oleg Ranevskyy via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="m_-3922385260404622253gmail_msg">Hi Renato, Dean, Serge,<div class="m_-3922385260404622253gmail_msg"><br class="m_-3922385260404622253gmail_msg"></div><div class="m_-3922385260404622253gmail_msg">Just looked into the code and wanted to share some thoughts.</div><div class="m_-3922385260404622253gmail_msg"><br class="m_-3922385260404622253gmail_msg"></div><div class="m_-3922385260404622253gmail_msg"><div class="m_-3922385260404622253gmail_msg">This might be a compare_exchange_weak spurious failure. ARM is a weakly ordered CPU, but I am not sure whether spurious failures are really possible in a single threaded app. On the other hand, there is no other way for FDRLogging_init to fail in such a way (return XRAY_LOG_UNINITIALIZED instead of XRAY_LOG_INITIALIZED) without any extra output. This is also true for the 2nd test failure in FDRLogging_finalize, which uses a weak exchange too.</div><div class="m_-3922385260404622253gmail_msg"><br class="m_-3922385260404622253gmail_msg"></div><div class="m_-3922385260404622253gmail_msg">Probably, the weak exchange needs to be either replaced with a strong one or looped with more detailed CurrentStatus checks.</div></div></div><div dir="ltr" class="m_-3922385260404622253gmail_msg"><div class="m_-3922385260404622253gmail_msg"><div class="m_-3922385260404622253gmail_msg"><br class="m_-3922385260404622253gmail_msg"></div><div class="m_-3922385260404622253gmail_msg">Oleg</div></div></div><div dir="ltr" class="m_-3922385260404622253gmail_msg"><div class="gmail_extra m_-3922385260404622253gmail_msg"><br class="m_-3922385260404622253gmail_msg"><div class="gmail_quote m_-3922385260404622253gmail_msg">On Wed, Jan 25, 2017 at 2:02 PM, Renato Golin via llvm-dev <span dir="ltr" class="m_-3922385260404622253gmail_msg"><<a href="mailto:llvm-dev@lists.llvm.org" class="m_-3922385260404622253gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br class="m_-3922385260404622253gmail_msg"><blockquote class="gmail_quote m_-3922385260404622253gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dean/Serge,<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
I just spotted this on our bots:<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
First failure, unrelated commit:<br class="m_-3922385260404622253gmail_msg">
<a href="http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/3190" rel="noreferrer" class="m_-3922385260404622253gmail_msg" target="_blank">http://lab.llvm.org:8011/<wbr>builders/clang-cmake-armv7-<wbr>a15-full/builds/3190</a><br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
'XRay-Unit :: unit/XRayFDRLoggingTest/<wbr>FDRLoggingTest.Simple' FAILED<br class="m_-3922385260404622253gmail_msg">
llvm/projects/compiler-rt/lib/<wbr>xray/tests/unit/fdr_logging_<wbr>test.cc:55: Failure<br class="m_-3922385260404622253gmail_msg">
      Expected: FDRLogging_init(kBufferSize, kBufferMax, &Options,<br class="m_-3922385260404622253gmail_msg">
sizeof(FDRLoggingOptions))<br class="m_-3922385260404622253gmail_msg">
      Which is: 0<br class="m_-3922385260404622253gmail_msg">
To be equal to: XRayLogInitStatus::XRAY_LOG_<wbr>INITIALIZED<br class="m_-3922385260404622253gmail_msg">
      Which is: 2<br class="m_-3922385260404622253gmail_msg">
[  FAILED  ] FDRLoggingTest.Simple (0 ms)<br class="m_-3922385260404622253gmail_msg">
...<br class="m_-3922385260404622253gmail_msg">
 1 FAILED TEST<br class="m_-3922385260404622253gmail_msg">
==11476==XRay instrumentation map missing. Not initializing XRay.<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
Then a similar, but not identical error:<br class="m_-3922385260404622253gmail_msg">
<a href="http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/3191" rel="noreferrer" class="m_-3922385260404622253gmail_msg" target="_blank">http://lab.llvm.org:8011/<wbr>builders/clang-cmake-armv7-<wbr>a15-full/builds/3191</a><br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
'XRay-Unit :: unit/XRayFDRLoggingTest/<wbr>FDRLoggingTest.Simple' FAILED<br class="m_-3922385260404622253gmail_msg">
llvm/projects/compiler-rt/lib/<wbr>xray/tests/unit/fdr_logging_<wbr>test.cc:58: Failure<br class="m_-3922385260404622253gmail_msg">
      Expected: FDRLogging_finalize()<br class="m_-3922385260404622253gmail_msg">
      Which is: 2<br class="m_-3922385260404622253gmail_msg">
To be equal to: XRayLogInitStatus::XRAY_LOG_<wbr>FINALIZED<br class="m_-3922385260404622253gmail_msg">
      Which is: 4<br class="m_-3922385260404622253gmail_msg">
[  FAILED  ] FDRLoggingTest.Simple (0 ms)<br class="m_-3922385260404622253gmail_msg">
...<br class="m_-3922385260404622253gmail_msg">
 1 FAILED TEST<br class="m_-3922385260404622253gmail_msg">
==11476==XRay instrumentation map missing. Not initializing XRay.<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
Note 0->2 on the first, 2->4 on the second.<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
And then, for no reason, it's green again:<br class="m_-3922385260404622253gmail_msg">
<a href="http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/3192" rel="noreferrer" class="m_-3922385260404622253gmail_msg" target="_blank">http://lab.llvm.org:8011/<wbr>builders/clang-cmake-armv7-<wbr>a15-full/builds/3192</a><br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
Looks like an unstable test to me. :)<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
Can you guys have a look?<br class="m_-3922385260404622253gmail_msg">
<br class="m_-3922385260404622253gmail_msg">
Thanks!<br class="m_-3922385260404622253gmail_msg">
--renato<br class="m_-3922385260404622253gmail_msg">
______________________________<wbr>_________________<br class="m_-3922385260404622253gmail_msg">
LLVM Developers mailing list<br class="m_-3922385260404622253gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="m_-3922385260404622253gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="m_-3922385260404622253gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="m_-3922385260404622253gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br class="m_-3922385260404622253gmail_msg">
</blockquote></div><br class="m_-3922385260404622253gmail_msg"></div></div>
______________________________<wbr>_________________<br class="m_-3922385260404622253gmail_msg">
LLVM Developers mailing list<br class="m_-3922385260404622253gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="m_-3922385260404622253gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="m_-3922385260404622253gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="m_-3922385260404622253gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br class="m_-3922385260404622253gmail_msg">
</blockquote></div></div></div></div>
</blockquote></div><br></div></div>