<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - MCContext untyped bump allocator not suitable for MCInst."
href="https://bugs.llvm.org/show_bug.cgi?id=46900">46900</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>MCContext untyped bump allocator not suitable for MCInst.
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hgreving@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23789" name="attach_23789" title="Small reproducer">attachment 23789</a> <a href="attachment.cgi?id=23789&action=edit" title="Small reproducer">[details]</a></span>
Small reproducer
Allocating MCInst with MCContext's overloaded 'new' can lead to a memory leak.
The reason is that MCInst contains a SmallVector<MCOperand, 8>. The SmallVector
is POD only for <= 8 operands. The default untyped bump pointer allocator of
MCContext does not delete the MCInst.
Small reproducer:
./llvm-project/install/bin/clang++ -O0 -g3 -c -o mcinst.o
`./llvm-project/install/bin/llvm-config --cxxflags` -fsanitize=address
mcinst.cc
./llvm-project/install/bin/clang++ mcinst.o
`./llvm-project/install/bin/llvm-config --ldflags --libs` -lpthread -ltinfo
-ldl -lz -fsanitize=address -o mcinst
ASAN_SYMBOLIZER_PATH=./llvm-project/install/bin/llvm-symbolizer ./test
Thanks to Marcello Maggioni and Thomas Raoux for helping to find this.
Suggested patch:
<a href="https://reviews.llvm.org/D84896">https://reviews.llvm.org/D84896</a></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>