[PATCH] [Tsan] Fix the signal_recursive.cc test to pass on systems with high loads

Dmitry Vyukov dvyukov at google.com
Mon Dec 8 13:49:04 PST 2014


================
Comment at: test/tsan/process_sleep.h:4
@@ +3,3 @@
+static void process_sleep(int sec) {
+  clock_t beg = clock();
+  while((clock() - beg) / CLOCKS_PER_SEC < sec)
----------------
Humm... clock() returns CPU time used by the process.
It looks somewhat dangerous to use in most of the tests. If the process is blocked it does not consume CPU time. Of course, this very loop consumes a dash of CPU time every millisecond... But it's not what we want to wait for.
sleep(1) worked well for us all other tests. I would rather it here as well.

================
Comment at: test/tsan/signal_recursive.cc:45
@@ -42,3 +44,3 @@
   do {
     g_busy_thread_received_restart = false;
     if (sigsuspend(&g_suspend_handler_mask) != -1 || errno != EINTR)
----------------
Please remove this line as well. It not only pointless, but also wrong. If the signal comes before this line, we lose the signal and deadlock.
Maybe it will fix the test w/o sleep...

http://reviews.llvm.org/D6504






More information about the llvm-commits mailing list