<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - coverage flushing unlocks and closes file in the wrong order"
href="https://llvm.org/bugs/show_bug.cgi?id=26847">26847</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>coverage flushing unlocks and closes file in the wrong order
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>todd@cloudera.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>