[compiler-rt] r223121 - [Tsan] Do not flush all streams on exit
Viktor Kutuzov
vkutuzov at accesssoftek.com
Tue Dec 2 06:59:51 PST 2014
Author: vkutuzov
Date: Tue Dec 2 08:59:51 2014
New Revision: 223121
URL: http://llvm.org/viewvc/llvm-project?rev=223121&view=rev
Log:
[Tsan] Do not flush all streams on exit
Differential Revision: http://reviews.llvm.org/D6462
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=223121&r1=223120&r2=223121&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Tue Dec 2 08:59:51 2014
@@ -1800,9 +1800,16 @@ TSAN_INTERCEPTOR(uptr, fwrite, const voi
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);
}
More information about the llvm-commits
mailing list