http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49484

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-17
     Ever Confirmed|0                           |1

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-17 
13:50:49 UTC ---
Confirmed with the testcase in the RH bugzilla.

I'm not sure why the issue does not reproduce with GCC 4.4 and up (I can't
see changes in libgcov).  But I can fix the issue by making the fcntl file
locking effective for threads with

Index: gcc/gcov-io.c
===================================================================
--- gcc/gcov-io.c       (revision 183243)
+++ gcc/gcov-io.c       (working copy)
@@ -32,6 +32,10 @@ static const gcov_unsigned_t *gcov_read_
 static void gcov_allocate (unsigned);
 #endif

+#if GCOV_LOCKED
+#include <sys/syscall.h>
+#endif
+
 static inline gcov_unsigned_t from_file (gcov_unsigned_t value)
 {
 #if !IN_LIBGCOV
@@ -70,9 +74,13 @@ gcov_open (const char *name, int mode)
   s_flock.l_whence = SEEK_SET;
   s_flock.l_start = 0;
   s_flock.l_len = 0; /* Until EOF.  */
+#ifdef SYS_gettid
+  s_flock.l_pid = syscall(SYS_gettid);
+#else
   s_flock.l_pid = getpid ();
 #endif
-  
+#endif
+
   gcc_assert (!gcov_var.file);
   gcov_var.start = 0;
   gcov_var.offset = gcov_var.length = 0;

Reply via email to