<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 --- - ASan failed to catch overrelease of block using Block_release"
href="https://llvm.org/bugs/show_bug.cgi?id=31061">31061</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ASan failed to catch overrelease of block using Block_release
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</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>jordan_rose@apple.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>Blocks, enabled by -fblocks, are a reference-counted data type once copied to
the heap using Block_copy; when compiling for Objective-C on Apple platforms
they are also valid Objective-C objects that respond to -copy, -retain, and
-release. ASan fails to catch the overrelease of a simple block copied to the
heap, as demonstrated by the following code.
---
// clang -fsanitize=address -fblocks
#include <stdio.h>
#include <Block.h>
int main(int argc, const char *argv[]) {
__typeof(^{}) block = ^{ printf("%d\n", argc); };
block = Block_copy(block);
block();
Block_release(block);
Block_release(block); // overrelease
// Note that the -release message and Block_release are interchangeable for
blocks.
}</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>