Skip to content

program crashes at movaps, unaligned stack address, -O3 #33385

@llvmbot

Description

@llvmbot
Bugzilla Link 34038
Resolution FIXED
Resolved on Aug 07, 2017 13:07
Version 4.0
OS Linux
Blocks #33196
Attachments C program for repro
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic,@zmodem,@hfinkel,@RKSimon,@rnk

Extended Description

ericy@mrpink:~$ /usr/bin/clang --version
clang version 4.0.0-1ubuntu1 (tags/RELEASE_400/rc1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

ericy@mrpink:~$ /usr/bin/clang -O3 movaps_unaligned_crash.c && ./a.out
Segmentation fault

It does not repro with -O2.

You can see that it used the movaps instruction with an unaligned address.

(gdb) disassemble
Dump of assembler code for function main:
0x0000000000400490 <+0>: sub $0x28,%rsp
0x0000000000400494 <+4>: movq $0x0,0x20(%rsp)
0x000000000040049d <+13>: movq $0x0,0x18(%rsp)
0x00000000004004a6 <+22>: mov 0x200b7b(%rip),%rax # 0x601028
=> 0x00000000004004ad <+29>: movaps 0x18(%rsp),%xmm0
0x00000000004004b2 <+34>: movaps %xmm0,(%rsp)
0x00000000004004b6 <+38>: mov $0x601028,%edi
0x00000000004004bb <+43>: xor %esi,%esi
0x00000000004004bd <+45>: xor %edx,%edx
0x00000000004004bf <+47>: xor %ecx,%ecx
0x00000000004004c1 <+49>: xor %r8d,%r8d
0x00000000004004c4 <+52>: callq *(%rax)
0x00000000004004c6 <+54>: xor %eax,%eax
0x00000000004004c8 <+56>: add $0x28,%rsp
0x00000000004004cc <+60>: retq
End of assembler dump.
(gdb) p $rsp
$1 = (void *) 0x7fffffffdf50

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions