ev_async race condition??

Marc Lehmann schmorp at schmorp.de
Sun May 22 06:47:09 CEST 2016

On Fri, May 20, 2016 at 02:01:00PM -0500, Jose Madrigal <mac.yosef at gmail.com> wrote:
> Hi!! I'm using libev in a multithreading project and I'm debugging with
> ThreadSanitizer from clang.  The ThreadSanitizer says there is a data race
> in libev, but i'm not sure if it is a false positive.

There aren't any known data races in libev. Maybe there is one, but clang
tends to be comparatively buggy (clang historically diagnosed all kinds of
bugs in libev when there weren't any), so at the moment I tend to assume
that it's a false positive.

> I'm wake up a event loop using ev_async because belongs to another thread.
> This is not supposed cause races.


> And then when I take a look on those files the variable that apparently
> races is "pipe_write_skipped" but in the code looks like is a
> "sig_atomic_t" type that should not be causing races.

sig_atomic_t unfortunately doesn't make any guarantees w.r.t. threads, we use
it only because there's not better portable type available and it happens to
work correctly everywhere we know.

> Is there any chances that this race condition is real or is just a false
> positive??

Unless you compiled out synchronisation primitives with ECB_NO_THREADS or
EV_NO_SMP it's probably a false positive till proven otherwise :)

> Sorry if I was not clear enough or I misspoke, english is not my strong

The interesting question is: did you run into any trouble, or is this just
about some clang warning? If the latter, then most likely you can ignore


                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list