[cfe-users] Silencing errors in TSAN

JVApen via cfe-users cfe-users at lists.llvm.org
Wed Feb 5 10:30:49 PST 2020


Hey Kyle,

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.

Timing ain't a good way to synchronize threads. TSan is correct in flagging
this occurrence.


On Fri, Jan 24, 2020, 16:15 Kyle Edwards via cfe-users <
cfe-users at lists.llvm.org> wrote:

> Hello all,
>
> I am attempting to build OpenMPI with TSAN enabled (to TSAN-itize a
> project that uses OpenMPI), and am finding that OpenMPI throws lots of
> errors in TSAN (not surprising.) I am attempting to build OpenMPI with
> the following blacklist:
>
> src:*
>
> However, I am still getting errors when I run mpiexec. I've reduced it
> down to the following minimal example:
>
> --
>
> #include <thread>
>
> #include <unistd.h>
>
> static int my_pipe[2];
>
> int main()
> {
>   pipe(my_pipe);
>   std::thread([]() {
>     std::this_thread::sleep_for(std::chrono::seconds(1));
>     close(my_pipe[1]);
>   }).detach();
>   write(my_pipe[1], "Hello", 5);
>   std::this_thread::sleep_for(std::chrono::seconds(2));
>   return 0;
> }
>
> --
>
> Even when I compile this with -fsanitize-blacklist=blacklist.txt, I
> still get a warning about a race condition. Is there some way I can
> silence this, preferably without patching OpenMPI? Is this a bug in
> TSAN?
>
> Kyle
> _______________________________________________
> cfe-users mailing list
> cfe-users at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20200205/d890c878/attachment.html>


More information about the cfe-users mailing list