[compiler-rt] r262779 - [GCDA] Unlock arc file before closing it

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 5 12:10:25 PST 2016


Author: vedantk
Date: Sat Mar  5 14:10:25 2016
New Revision: 262779

URL: http://llvm.org/viewvc/llvm-project?rev=262779&view=rev
Log:
[GCDA] Unlock arc file before closing it

The GCDA writer closed the arc file before unlocking it. This causes an
EBADF while unlocking the file, and opens us up to racy behavior.

Fixes PR26847.

Modified:
    compiler-rt/trunk/lib/profile/GCDAProfiling.c

Modified: compiler-rt/trunk/lib/profile/GCDAProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?rev=262779&r1=262778&r2=262779&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/GCDAProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/GCDAProfiling.c Sat Mar  5 14:10:25 2016
@@ -486,8 +486,8 @@ void llvm_gcda_end_file() {
       unmap_file();
     }
 
-    fclose(output_file);
     flock(fd, LOCK_UN);
+    fclose(output_file);
     output_file = NULL;
     write_buffer = NULL;
   }




More information about the llvm-commits mailing list