diff options
author | Viktor Kutuzov <vkutuzov@accesssoftek.com> | 2014-12-02 14:59:51 +0000 |
---|---|---|
committer | Viktor Kutuzov <vkutuzov@accesssoftek.com> | 2014-12-02 14:59:51 +0000 |
commit | 01eb1642389985c575bd7744f1c42b7ae58154cc (patch) | |
tree | fc3341d31bc00caf41e3e513ab18c88fda03234e | |
parent | b3c6665a733a3523e908a72280dbb9dca648ea26 (diff) |
[Tsan] Do not flush all streams on exit
Differential Revision: http://reviews.llvm.org/D6462
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223121 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/tsan/rtl/tsan_interceptors.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc index 788994291..5bede0ec7 100644 --- a/lib/tsan/rtl/tsan_interceptors.cc +++ b/lib/tsan/rtl/tsan_interceptors.cc @@ -1800,9 +1800,16 @@ TSAN_INTERCEPTOR(uptr, fwrite, const void *p, uptr size, uptr nmemb, void *f) { return REAL(fwrite)(p, size, nmemb, f); } +static void FlushStreams() { + // Flushing all the streams here may freeze the process if a child thread is + // performing file stream operations at the same time. + REAL(fflush)(stdout); + REAL(fflush)(stderr); +} + TSAN_INTERCEPTOR(void, abort, int fake) { SCOPED_TSAN_INTERCEPTOR(abort, fake); - REAL(fflush)(0); + FlushStreams(); REAL(abort)(fake); } @@ -2131,7 +2138,7 @@ TSAN_INTERCEPTOR(int, vfork, int fake) { static int OnExit(ThreadState *thr) { int status = Finalize(thr); - REAL(fflush)(0); + FlushStreams(); return status; } @@ -2367,10 +2374,7 @@ static void finalize(void *arg) { ThreadState *thr = cur_thread(); int status = Finalize(thr); // Make sure the output is not lost. - // Flushing all the streams here may freeze the process if a child thread is - // performing file stream operations at the same time. - REAL(fflush)(stdout); - REAL(fflush)(stderr); + FlushStreams(); if (status) REAL(_exit)(status); } |