[llvm-bugs] [Bug 43528] New: [CodeGen] Wrong codegen mwait intrinsic + Asan + stack protector
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 1 11:01:01 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43528
Bug ID: 43528
Summary: [CodeGen] Wrong codegen mwait intrinsic + Asan + stack
protector
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: pierregousseau14 at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
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.
--
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/20191001/419c70f7/attachment.html>
More information about the llvm-bugs
mailing list