A bit more debugging I see that signal comes from kernel (si_code=0x80) but it claims null pointer reference. I don't understand how it could be a null pointer .... I would need to have better understanding what happens in gdb and kernel to trigger the SIGSEGV.
I found out also that workaround is to have breakpoint but disable it after stopping on the problematic instruction. If breakpoint isn't active then execution continues without issues. Only issues is that I don't know full set of instructions which actually trigger this issue. I have had issues with some other memory referencing VEX coded instructions. But I also have examples of memory reference instructions which don't trigger the bug.
I attached updated test2.cc which has now signal handling dumping siginfo.
Reading symbols from ./test2...
(gdb) b main
Breakpoint 1 at 0x650: file test2.cc, line 41.
(gdb) r
Starting program: /home/coren/project/test2
Breakpoint 1, main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb) disassemble
Dump of assembler code for function main():
=> 0x0000555555554650 <+0>: vmovdqa 0x19d8(%rip),%xmm0 # 0x555555556030 <foo>
0x0000555555554658 <+8>: vmovd %xmm0,%eax
0x000055555555465c <+12>: retq
End of assembler dump.
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb)
Continuing.
sig: 11, ctx: 0x7fffffffd740
si_signo: 11, si_erron: 0, si_code: 128
si_addr: (nil), si_addr_lsb: 0, si_pid: 0, si_uid: 0
Breakpoint 1, main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb)
Continuing.
Program received signal SIGSEGV, Segmentation fault.
main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb)
Continuing.
sig: 11, ctx: 0x7fffffffd740
si_signo: 11, si_erron: 0, si_code: 128
si_addr: (nil), si_addr_lsb: 0, si_pid: 0, si_uid: 0
Breakpoint 1, main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb) dis 1
(gdb) c
Continuing.
[Inferior 1 (process 9091) exited with code 01]
A bit more debugging I see that signal comes from kernel (si_code=0x80) but it claims null pointer reference. I don't understand how it could be a null pointer .... I would need to have better understanding what happens in gdb and kernel to trigger the SIGSEGV.
I found out also that workaround is to have breakpoint but disable it after stopping on the problematic instruction. If breakpoint isn't active then execution continues without issues. Only issues is that I don't know full set of instructions which actually trigger this issue. I have had issues with some other memory referencing VEX coded instructions. But I also have examples of memory reference instructions which don't trigger the bug.
I attached updated test2.cc which has now signal handling dumping siginfo.
Reading symbols from ./test2... project/ test2
(gdb) b main
Breakpoint 1 at 0x650: file test2.cc, line 41.
(gdb) r
Starting program: /home/coren/
Breakpoint 1, main () at test2.cc:41 554658 <+8>: vmovd %xmm0,%eax 55465c <+12>: retq
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb) disassemble
Dump of assembler code for function main():
=> 0x0000555555554650 <+0>: vmovdqa 0x19d8(%rip),%xmm0 # 0x555555556030 <foo>
0x0000555555
0x0000555555
End of assembler dump.
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb)
Continuing.
sig: 11, ctx: 0x7fffffffd740
si_signo: 11, si_erron: 0, si_code: 128
si_addr: (nil), si_addr_lsb: 0, si_pid: 0, si_uid: 0
Breakpoint 1, main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb)
Continuing.
Program received signal SIGSEGV, Segmentation fault.
main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb)
Continuing.
sig: 11, ctx: 0x7fffffffd740
si_signo: 11, si_erron: 0, si_code: 128
si_addr: (nil), si_addr_lsb: 0, si_pid: 0, si_uid: 0
Breakpoint 1, main () at test2.cc:41
41 asm("\tvmovdqa %1, %0\n" : "=x" (bar) : "xm" (foo));
(gdb) dis 1
(gdb) c
Continuing.
[Inferior 1 (process 9091) exited with code 01]