http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56375
Bug #: 56375
Summary: SIGSEGV when assign SIMD variable to member of
allocated structure
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: cj...@126.com
The code:
#include malloc.h
typedef float v4 __attribute__((vector_size(sizeof(float)*4)));
typedef struct IpuImage
{
v4 data[256*256];
}
IpuImage;
int main()
{
IpuImage * I = malloc(sizeof(IpuImage));
v4 color = {1, 0, 1, 0};
I-data[0] = color;
return 0;
}
I use this to compile:
gcc -o a a.c -std=gnu11 -march=native
SIGSEGV happens at I-data[0] = color
Then I tried to debug in assembly mode, following is the gdb's output:
┌──Register group:
general─┐
│eax0xb7d29008 -1210937336
│
│ecx0x101000 1052672
│
│edx0xb7d29008 -1210937336
│
│ebx0xb7fd8000 -1208123392
│
│esp0xb370 0xb370
│
│ebp0xb3a8 0xb3a8
│
│esi0x0 0
│
│edi0x0 0
│
│eip0x804842a0x804842a main+46
│
│eflags 0x210282 [ SF IF RF ID ]
│
cs 0x73 115
│
│ss 0x7b 123
│
└──┘
│0x8048411 main+21 mov%eax,0x2c(%esp)
│
│0x8048415 main+25 movaps 0x80484e0,%xmm0
│
│0x804841c main+32 movaps %xmm0,0x10(%esp)
│
│0x8048421 main+37 mov0x2c(%esp),%eax
│
│0x8048425 main+41 movaps 0x10(%esp),%xmm0
│
│0x804842a main+46 movaps %xmm0,(%eax)
│
│0x804842d main+49 mov$0x0,%eax
│
│0x8048432 main+54 leave
│
│0x8048433 main+55 ret
│
│0x8048434 xchg %ax,%ax
│
│0x8048436 xchg %ax,%ax
│
│0x8048438 xchg %ax,%ax
│
│0x804843a xchg %ax,%ax
│
└───┘
child process 7781 In: mainLine: ?? PC: 0x804842a
(gdb) ni
0x08048402 in main ()
0x08048405 in main ()
0x0804840c in main ()
0x08048411 in main ()
0x08048415 in main ()
0x0804841c in main ()
0x08048421 in main ()
0x08048425 in main ()
0x0804842a in main ()
Program received signal SIGSEGV, Segmentation fault.
0x0804842a in main ()
(gdb)
%eax is non-zero, showing that malloc succeeded, and SIGSEGV is occured at
movaps %xmm0,(%eax)