[LLVMbugs] [Bug 16821] New: Infinite loops in generated assembly when using -D_FORTIFY_SOURCE=2 and -O1
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Aug 7 07:35:39 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16821
Bug ID: 16821
Summary: Infinite loops in generated assembly when using
-D_FORTIFY_SOURCE=2 and -O1
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: zandobersek at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 10999
--> http://llvm.org/bugs/attachment.cgi?id=10999&action=edit
Test case
Attached is a reduced and simplified test case (originating from WebKit) that
loops infinitely when compiled compiled with Clang and specifying both
-D_FORTIFY_SOURCE=2 and -O1 on the command line.
Breaking the loop under GDB stops in the randomValue function and disassembly
sure enough shows the problem:
-----
Program received signal SIGINT, Interrupt.
0x0000000000400620 in randomValue(unsigned char*, unsigned long) ()
(gdb) disassemble
Dump of assembler code for function _Z11randomValuePhm:
0x0000000000400600 <+0>: push %rax
0x0000000000400601 <+1>: mov $0x4006f4,%edi
0x0000000000400606 <+6>: xor %esi,%esi
0x0000000000400608 <+8>: xor %edx,%edx
0x000000000040060a <+10>: xor %eax,%eax
0x000000000040060c <+12>: callq 0x4004f0 <open at plt>
0x0000000000400611 <+17>: test %eax,%eax
0x0000000000400613 <+19>: js 0x400622 <_Z11randomValuePhm+34>
0x0000000000400615 <+21>: data32 nopw %cs:0x0(%rax,%rax,1)
=> 0x0000000000400620 <+32>: jmp 0x400620 <_Z11randomValuePhm+32>
0x0000000000400622 <+34>: callq 0x4005f0 <WTFCrash>
End of assembler dump.
-----
The clang command used:
clang++ -D_FORTIFY_SOURCE=2 -O2 -stdlib=libstdc++ -o test test.cpp
Notes:
- setting _FORTIFY_SOURCE to 0 or disabling any optimizations fixes the
problem,
- the problem persists when specifying any other non-null level of
optimization,
- I'm using Clang 3.4 (trunk) on Ubuntu 13.04, hence also the libstdc++ choice,
- I've experienced the same problem with older versions of Clang, from at least
3.0 onwards.
--
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/20130807/03554ac4/attachment.html>
More information about the llvm-bugs
mailing list