1

I've got a program that's SIGSEGV'ing in library code. Nothing is jumping out at me when looking at the statement that's causing the SIGSEGV (see below). But the code uses Intel's AES-NI, and I'm not that familiar with it.

I issued handle all in hopes of catching the trap that's causing the SIGSEGV, but the program still just crashes rather than telling me the trap.

How can I get GDB to display the CPU trap that's causing the SIGSEGV?


Program received signal SIGSEGV, Segmentation fault.
0x00000000004ddf0b in CryptoPP::AESNI_Dec_Block(long long __vector&, long long __vector const*, unsigned int) (block=..., subkeys=0x7fffffffdc60, rounds=0x0)
    at rijndael.cpp:1040
1040            block = _mm_aesdec_si128(block, subkeys[i+1]);
(gdb) p block
$1 = (__m128i &) @0x7fffffffcec0: {0x2e37c840668d6030, 0x431362358943e432}
(gdb) x/16b 0x7fffffffcec0
0x7fffffffcec0: 0x30    0x60    0x8d    0x66    0x40    0xc8    0x37    0x2e
0x7fffffffcec8: 0x32    0xe4    0x43    0x89    0x35    0x62    0x13    0x43
4

2 回答 2

1

这些指令是相当新的(AVX)。也可能是 CPU 不支持该指令,或者操作系统未配置为允许它们。我知道在这种情况下通常会期望 SIGILL,但是 x86 会在它生成的异常中令人惊讶,特别是如果操作系统禁用了 CPU 支持的指令的使用,SIGSEGV 是很常见的。(如果我的语气不清楚,我只是在这里猜测,只是说这是你可能想要调查的调查途径。)

于 2015-04-07T11:00:17.297 回答
1

如何让 GDB 显示导致 SIGSEGV 的 CPU 陷阱

你不能:GDB 看不到陷阱,只有操作系统可以。

您可以看到导致陷阱的指令:

(gdb) x/i $pc

问题很可能是对齐。我不知道是什么long long __vector,但如果它不是一个 16 字节的实体,那么subkeys[i+1]就不会是 16 字节对齐的,这对 来说是个问题_mm_aesdec_si128,因为它需要两个参数都对齐 16 字节。

于 2015-04-07T04:02:44.853 回答