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

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-17 
15:39:19 UTC ---
strace showing that file-locking, even with using gettid doesn't work:

16980 gettid( <unfinished ...>
16981 gettid()                          = 16981
16981 open("/tmp/t.gcda", O_RDWR|O_CREAT, 0666) = 3
16981 fcntl(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
16981 fcntl(3, F_GETFL)                 = 0x8002 (flags O_RDWR|O_LARGEFILE)
16981 close(3)                          = 0
16980 <... gettid resumed> )            = 16980
16980 open("/tmp/t.gcda", O_RDWR|O_CREAT, 0666) = 3
16980 fcntl(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
16980 fcntl(3, F_GETFL)                 = 0x8002 (flags O_RDWR|O_LARGEFILE)
16982 gettid()                          = 16982
16982 open("/tmp/t.gcda", O_RDWR|O_CREAT, 0666) = 3
16982 fcntl(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}
<unfinished ...>
16983 gettid()                          = 16983
16983 --- SIGABRT (Aborted) @ 0 (0) ---
16982 <... fcntl resumed> )             = 0
16979 +++ killed by SIGABRT (core dumped) +++
16982 fcntl(3, F_GETFL)                 = 0x8002 (flags O_RDWR|O_LARGEFILE)
16982 close(3)                          = 0

it seems that the first close of fd 3 makes all further locks (even to
different l_pid) noops.  I suppose l_pid is simply ignored ofr F_SETLK[W]
and the current PID is used.  That makes the file-locking in libgcov
non-thread-safe.

Reply via email to