[llvm-bugs] [Bug 26847] New: coverage flushing unlocks and closes file in the wrong order

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 4 17:19:55 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26847

            Bug ID: 26847
           Summary: coverage flushing unlocks and closes file in the wrong
                    order
           Product: compiler-rt
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: todd at cloudera.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

When using GCDA profiling, the flush process tries to flock/funlock the GCDA
files to prevent multi-process races. However, the code that closes the file
seems to be wrong: it calls 'unlock' on the file _after_ closing it, which
results in EBADF:

open("/tmp/test.gcda", O_RDWR)          = -1 ENOENT (No such file or directory)
open("/tmp/test.gcda", O_RDWR|O_CREAT, 0644) = 3
flock(3, LOCK_EX)                       = 0
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f2b2e397000
lseek(3, 0, SEEK_CUR)                   = 0
write(3, "adcg*204J\310\376B\0\0\0\1\5\0\0\0\0\0\0\0\211EN;\2\0\0\0"..., 124) =
124
close(3)                                = 0
munmap(0x7f2b2e397000, 4096)            = 0
flock(3, LOCK_UN)                       = -1 EBADF (Bad file descriptor)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160305/9ad13654/attachment-0001.html>


More information about the llvm-bugs mailing list