diff --git a/test/test-async.c b/test/test-async.c index efcfe15a..26194a1f 100644 --- a/test/test-async.c +++ b/test/test-async.c @@ -50,6 +50,21 @@ void thread_cb(void *arg) { r = uv_async_send(&async); ASSERT(r == 0); + + /* Work around a bug in Valgrind. + * + * Valgrind runs threads not in parallel but sequentially, i.e. one after + * the other. It also doesn't preempt them, instead it depends on threads + * yielding voluntarily by making a syscall. + * + * That never happens here: the pipe that is associated with the async + * handle is written to once but that's too early for Valgrind's scheduler + * to kick in. Afterwards, the thread busy-loops, starving the main thread. + * Therefore, we yield. + * + * This behavior has been observed with Valgrind 3.7.0 and 3.9.0. + */ + uv_sleep(0); } }