This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug gcov-profile/49484] gcov crash if two(or more) forks happen at the same time
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 17 Jan 2012 13:50:49 +0000
- Subject: [Bug gcov-profile/49484] gcov crash if two(or more) forks happen at the same time
- Auto-submitted: auto-generated
- References: <bug-49484-4@http.gcc.gnu.org/bugzilla/>
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;