Permalink
Browse files

test: work around valgrind bug

  • Loading branch information...
1 parent 43d52c7 commit 2d1f17fecbdc40370e9daa39dc351fcd5e47164c @bnoordhuis bnoordhuis committed Nov 9, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 test/test-async.c
View
@@ -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);
}
}

0 comments on commit 2d1f17f

Please sign in to comment.