DLTcollab/sse2neon

Crash in test_mm_stream_si128() due to unaligned access

jonathanhue opened this issue · 0 comments

Crash has been observed with 32-bit executables running on actual ARM hardware running both 32-bit and 64-bit operating systems. The crash is due to trying to store to an insufficiently aligned address. _mm_stream_si128 requires that the destination address be aligned on a 16-byte boundary, otherwise a general protection fault may occur. sse2neon maps this to vst1q_s64, and the address only has 4-byte alignment, so a bus error occurs. So the test needs to be fixed to align the memory address.

Changing:

int32_t p[4];

to

int32_t p[4] __attribute__ ((aligned (16)));

is one way to enable the test to pass. Note that _mm_store_si128 has the same alignment requirements as _mm_stream_si128, so test_mm_store_si128 would also crash on an actual x86 if p were not sufficiently aligned. It does not crash on an ARM though because _mm_store_si128 is mapped to vst1q_s32, and it has relaxed alignment requirements in my environment.