Unaligned access in `initGcThreads`?
While attempting to build a ARMv7 bindist for %9.2.2 I found that GHC would throw a bus error under certain conditions.
The culprit appears to be
Thread 1 "ghc-stage2" received signal SIGBUS, Bus error.
init_gc_thread (t=0x1e737b8) at rts/sm/GC.c:1872
1872 t->copied = 0;
(gdb) disassemble
Dump of assembler code for function initGcThreads:
0xef486334 <+0>: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
0xef486338 <+4>: sub sp, sp, #4
...
0xef4864a4 <+368>: ldr r1, [pc, #360] ; 0xef486614 <initGcThreads+736>
0xef4864a8 <+372>: ldr r1, [pc, r1]
0xef4864ac <+376>: str r1, [r2, #24]
0xef4864b0 <+380>: str r1, [r2, #20]
0xef4864b4 <+384>: add r1, r2, #48 ; 0x30
0xef4864b8 <+388>: ldr r0, [r0, #900] ; 0x384
=> 0xef4864bc <+392>: vst1.64 {d8-d9}, [r1 :128]
0xef4864c0 <+396>: mov r1, #256 ; 0x100
0xef4864c4 <+400>: strh r1, [r2, #44] ; 0x2c
0xef4864c8 <+404>: str r8, [r2, #40] ; 0x28
...
(gdb) print/x $r1
$2 = 0x1e737e8
vst
is apparently a NEON instruction and this particular encoding appears to require 16 byte alignment, which is clearly not satisfied.
Frankly, I suspect that this may be a clang-13
bug (which is the compiler that I used to bootstrap) as this is C code and surely it should not have chosen this encoding unless it could prove that the pointer is sufficiently aligned.