<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 - [CodeGen] Wrong codegen mwait intrinsic + Asan + stack protector"
href="https://bugs.llvm.org/show_bug.cgi?id=43528">43528</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[CodeGen] Wrong codegen mwait intrinsic + Asan + stack protector
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pierregousseau14@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>clang version 10.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
17380227e830a7a3fc2adafc2226e4c579b919ef)
Target: x86_64-unknown-linux-gnu
llvm-svn: 373195
This example seems to generate incorrect code, code gen for mwaitx overwrites
ebx.
rbx is set as the stack base pointer.
Stack protector code dereferences rbx and causes a segfault.
"""
static __inline__ void __attribute__((__always_inline__))
_mm_monitorx(void const * __p, unsigned __extensions, unsigned __hints)
{
__builtin_ia32_monitorx((void *)__p, __extensions, __hints);
}
static __inline__ void __attribute__((__always_inline__))
_mm_mwaitx(unsigned __extensions, unsigned __hints, unsigned __clock)
{
__builtin_ia32_mwaitx(__extensions, __hints, __clock);
}
int main(int argc, char ** argv) {
int v;
v = 0;
_mm_monitorx(&v, 0, 0);
_mm_mwaitx(0, 0, 1);
}
"""
clang -fsanitize=address -g -fstack-protector-strong -mmwaitx test.cpp &&
./a.out
==5252==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc
0x0000004ebd15 bp 0x7ffe71535d00 sp 0x7ffe71535c20 T0)
==5252==The signal is caused by a READ memory access.
==5252==Hint: address points to the zero page.</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>