https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91043
Bug ID: 91043
Summary: GCC produces unaligned vmovdqa vector data access
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hhaim at cisco dot com
Target Milestone: ---
**The project**:
https://github.com/cisco-system-traffic-generator/trex-core
**how to compile**:
https://github.com/cisco-system-traffic-generator/trex-core/wiki#how-to-build-trex
The commit with a workaround:
https://github.com/cisco-system-traffic-generator/trex-core/commit/39e7f535f96f0f5b4406db667be7bc775ce3e515
**The issue**:
gcc 7/8 generate vector instruction on a variables that was allocated by the
gcc and it seems as not aligned
the struct is defined like that
static CGlobalTRex g_trex;
It includes
CLatencyManager m_mg;
which includes
CLatencyManagerPerPort m_ports[TREX_MAX_PORTS];
class CLatencyManagerPerPort {
public:
CCPortLatency m_port; << crash is on the function reset of this
object
CPortLatencyHWBase * m_io;
uint32_t m_flag;
};
**Workaround**:
Adding no-sse to this function solves the issue
__attribute__((noinline,target("no-sse2")))
void CCPortLatency::reset(){
void CCPortLatency::reset(){
warning: bad breakpoint number at or near '0x585763'
(gdb) disassemble 0x585763
Dump of assembler code for function CCPortLatency::Create(unsigned char,
unsigned short, unsigned short, unsigned short, CCPortLatency*,
CLatencyPktMode*, CNatRxManager*):
0x00000000005856a0 <+0>: push %rbp
0x00000000005856a1 <+1>: mov %rsp,%rbp
0x00000000005856a4 <+4>: push %r12
0x00000000005856a6 <+6>: push %r10
0x00000000005856a8 <+8>: lea 0x10(%rbp),%r10
0x00000000005856ac <+12>: push %rbx
0x00000000005856ad <+13>: mov %rdi,%rbx
0x00000000005856b0 <+16>: sub $0x8,%rsp
0x00000000005856b4 <+20>: mov (%r10),%rax
0x00000000005856b7 <+23>: movb $0x0,0x3f(%rbx)
0x00000000005856bb <+27>: mov 0x8(%r10),%rdi
0x00000000005856bf <+31>: mov %rax,(%rbx)
0x00000000005856c2 <+34>: test %rax,%rax
0x00000000005856c5 <+37>: je 0x585795 <CCPortLatency::Create(unsigned
char, unsigned short, unsigned short, unsigned short, CCPortLatency*,
CLatencyPktMode*, CNatRxManager*)+245>
0x00000000005856cb <+43>: mov %esi,%eax
0x00000000005856cd <+45>: mov %sil,0x31(%rbx)
0x00000000005856d1 <+49>: movzbl %sil,%esi
0x00000000005856d5 <+53>: not %eax
0x00000000005856d7 <+55>: mov %rdi,0x8(%rbx)
0x00000000005856db <+59>: and $0x1,%eax
0x00000000005856de <+62>: movb $0x1,0x3e(%rbx)
0x00000000005856e2 <+66>: movl $0x12345678,0x28(%rbx)
0x00000000005856e9 <+73>: movl $0x1,0x38(%rbx)
0x00000000005856f0 <+80>: mov %cx,0x34(%rbx)
0x00000000005856f4 <+84>: mov %dx,0x32(%rbx)
0x00000000005856f8 <+88>: mov %r8w,0x36(%rbx)
0x00000000005856fd <+93>: mov %r9,0x10(%rbx)
0x0000000000585701 <+97>: mov %al,0x19(%rbx)
0x0000000000585704 <+100>: mov %al,0x18(%rbx)
0x0000000000585707 <+103>: movq $0x0,0x1c(%rbx)
0x000000000058570f <+111>: cmpb $0x0,0xc2e938(%rsi)
0x0000000000585716 <+118>: je 0x585721 <CCPortLatency::Create(unsigned
char, unsigned short, unsigned short, unsigned short, CCPortLatency*,
CLatencyPktMode*, CNatRxManager*)+129>
0x0000000000585718 <+120>: movb $0x1,0x24(%rbx)
0x000000000058571c <+124>: movb $0x1,0x24(%r9)
0x0000000000585721 <+129>: lea 0x100(%rbx),%r12
---Type <return> to continue, or q <return> to quit---
0x0000000000585728 <+136>: mov %r12,%rdi
0x000000000058572b <+139>: callq 0x590320 <CTimeHistogram::Create()>
0x0000000000585730 <+144>: mov 0x6a8449(%rip),%rdi # 0xc2db80
<stdout@@GLIBC_2.2.5>
0x0000000000585737 <+151>: callq 0x4c5be0 <fflush@plt>
0x000000000058573c <+156>: mov 0x28(%rbx),%eax
0x000000000058573f <+159>: mov %r12,%rdi
0x0000000000585742 <+162>: vpxor %xmm0,%xmm0,%xmm0
0x0000000000585746 <+166>: movb $0x0,0x30(%rbx)
0x000000000058574a <+170>: movq $0x0,0xc0(%rbx)
0x0000000000585755 <+181>: movq $0x0,0xc8(%rbx)
0x0000000000585760 <+192>: mov %eax,0x2c(%rbx)
=> 0x0000000000585763 <+195>: vmovdqa %ymm0,0x40(%rbx) << crash here
0x0000000000585768 <+200>: vmovdqa %ymm0,0x60(%rbx)
0x000000000058576d <+205>: vmovdqa %ymm0,0x80(%rbx)
0x0000000000585775 <+213>: vmovdqa %ymm0,0xa0(%rbx)