This is an archive of the discontinued LLVM Phabricator instance.

Make tsan tests more portable
ClosedPublic

Authored by maxim-kuvyrkov on Mar 1 2016, 1:59 AM.

Details

Summary

... by avoiding potential races when scanning stdout and stderr output.

Diff Detail

Event Timeline

maxim-kuvyrkov retitled this revision from to Make tsan tests more portable.
maxim-kuvyrkov updated this object.
maxim-kuvyrkov added a reviewer: kcc.
maxim-kuvyrkov added a subscriber: llvm-commits.

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.

rengolin added a subscriber: rengolin.

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

dvyukov accepted this revision.Mar 1 2016, 2:40 AM
dvyukov edited edge metadata.

LGTM
Thanks for fixing this!

This revision is now accepted and ready to land.Mar 1 2016, 2:40 AM

Renato, would you please commit this for me?

rengolin closed this revision.Mar 2 2016, 3:14 AM

Sure! Committed in r262476.