... by avoiding potential races when scanning stdout and stderr output.
Diff Detail
Event Timeline
This patch improves sanitizer testsuite to avoid sporadic failures, especially when [cross-]testing on a remote machine.
There are several unstable sanitizer tests in LLVM testsuite (e.g., tsan/aligned_vs_unaligned_race.C), and the instability comes from the test doing this:
printf("Pass\n"); // CHECK: ThreadSanitizer: data race // CHECK: Pass
. Thread sanitizer prints its data to stderr, and then printf prints to stdout. The testcase expects stderr to be flushed before stdout, and "Pass" to be at the end of the output. AFAIK, that works fine in native/local environment, but fails in remote testing from time to time. The failure case happens when stdout output is printed before stderr output. This is, likely, because there is no strict ordering of stdout and stderr when remote testing.
there is no strict ordering of stdout and stderr when remote testing.
AFAIK, there is no strict ordering of stdout and stderr, period.
This is not a matter of flushing stdout, because there's still the concurrency issue between out and err. I believe this patch is correct, but I'll leave others more experienced in TSAN to approve.
cheers,
--renato