<div dir="auto"><div>Hey Kyle,<div dir="auto"><br></div><div dir="auto">This is a bug in your code, if you have a context switch after the creation of the thread on an overloaded system, the close of the pipe can be closed while writing or even before it.</div><div dir="auto"><br></div><div dir="auto">Timing ain't a good way to synchronize threads. TSan is correct in flagging this occurrence.</div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 24, 2020, 16:15 Kyle Edwards via cfe-users <<a href="mailto:cfe-users@lists.llvm.org">cfe-users@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">Hello all,<br>
<br>
I am attempting to build OpenMPI with TSAN enabled (to TSAN-itize a<br>
project that uses OpenMPI), and am finding that OpenMPI throws lots of<br>
errors in TSAN (not surprising.) I am attempting to build OpenMPI with<br>
the following blacklist:<br>
<br>
src:*<br>
<br>
However, I am still getting errors when I run mpiexec. I've reduced it<br>
down to the following minimal example:<br>
<br>
--<br>
<br>
#include <thread><br>
<br>
#include <unistd.h><br>
<br>
static int my_pipe[2];<br>
<br>
int main()<br>
{<br>
  pipe(my_pipe);<br>
  std::thread([]() {<br>
    std::this_thread::sleep_for(std::chrono::seconds(1));<br>
    close(my_pipe[1]);<br>
  }).detach();<br>
  write(my_pipe[1], "Hello", 5);<br>
  std::this_thread::sleep_for(std::chrono::seconds(2));<br>
  return 0;<br>
}<br>
<br>
--<br>
<br>
Even when I compile this with -fsanitize-blacklist=blacklist.txt, I<br>
still get a warning about a race condition. Is there some way I can<br>
silence this, preferably without patching OpenMPI? Is this a bug in<br>
TSAN?<br>
<br>
Kyle<br>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank" rel="noreferrer">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div></div></div>