Frequent "bus errors" on macOS Ventura / aarch64 / GHC 9.4.3
An application that I use and maintain, matterhorn, is crashing somewhat frequently on macOS Ventura in what appears to be GMP code. Here are the platform details:
- macOS version: Ventura 13.0.1
-
uname -a
:Darwin 000642-jtd.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64
- Chipset: Apple M1 Max
- GHC version: 9.4.3
- Cabal and
cabal-install
versions: 3.8.1.0
I don't know for sure, but this might be a duplicate of #22408. These crashes occur seemingly at random. Sometimes the program almost immediately fails to start; at other times it runs for a while before crashing. In all cases, Bus error: 10
is reported to the console.
Here are some crashes recorded from lldb
along with some additional information in a few cases. Please let me know if there's any additional testing or information that would be helpful!
* thread #4, stop reason = EXC_BAD_ACCESS (code=2, address=0x6ffffffff0)
frame #0: 0x00000001081da380 matterhorn`__gmpn_lshift + 176
matterhorn`:
-> 0x1081da380 <+176>: ldp x4, x5, [x1, #-0x10]
0x1081da384 <+180>: orr x10, x10, x13
0x1081da388 <+184>: orr x11, x12, x2
0x1081da38c <+188>: stp x10, x11, [x16, #-0x10]
Target 0: (matterhorn) stopped.
* thread #10, name = 'ghc_worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x16bf24000)
frame #0: 0x0000000108213174 matterhorn`__gmpn_sub_n + 156
matterhorn`:
-> 0x108213174 <+156>: stp x12, x13, [x0], #0x10
0x108213178 <+160>: sub x18, x18, #0x1
0x10821317c <+164>: cbnz x18, 0x108213150 ; <+120>
0x108213180 <+168>: sbcs x12, x6, x10
Target 0: (matterhorn) stopped.
* thread #9, name = 'ghc_worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x16db34000)
frame #0: 0x0000000106575f30 matterhorn`__gmpn_sqr_diag_addlsh1 + 80
matterhorn`:
-> 0x106575f30 <+80>: ldp x4, x5, [x1, #-0x10]
0x106575f34 <+84>: umulh x11, x17, x17
0x106575f38 <+88>: extr x8, x7, x6, #0x3f
0x106575f3c <+92>: stp x12, x13, [x0], #0x10
Target 0: (matterhorn) stopped.
* thread #4, stop reason = EXC_BAD_ACCESS (code=2, address=0x6ffffffff0)
frame #0: 0x0000000108cfa0a0 matterhorn`__gmpn_lshift + 176
matterhorn`:
-> 0x108cfa0a0 <+176>: ldp x4, x5, [x1, #-0x10]
0x108cfa0a4 <+180>: orr x10, x10, x13
0x108cfa0a8 <+184>: orr x11, x12, x2
0x108cfa0ac <+188>: stp x10, x11, [x16, #-0x10]
Target 0: (matterhorn) stopped.
(lldb) bt
* thread #4, stop reason = EXC_BAD_ACCESS (code=2, address=0x6ffffffff0)
* frame #0: 0x0000000108cfa0a0 matterhorn`__gmpn_lshift + 176
frame #1: 0x0000000108cee590 matterhorn`integer_gmp_mpn_lshift + 80
frame #2: 0x0000000108d2e598 matterhorn`Lc6z8_info + 52
frame #3: 0x0000000108de0584 matterhorn`schedule(initialCapability=<unavailable>, task=0x0000000109a25898) at Schedule.c:482:13 [opt]
* thread #7, name = 'ghc_worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x16d550000)
frame #0: 0x0000000106acc3c4 matterhorn`__gmpn_mul_1 + 156
matterhorn`:
-> 0x106acc3c4 <+156>: stp x12, x13, [x0, #-0x10]
0x106acc3c8 <+160>: adcs x12, x8, x11
0x106acc3cc <+164>: umulh x11, x5, x3
0x106acc3d0 <+168>: mul x8, x6, x3
Target 0: (matterhorn) stopped.
(lldb) bt
* thread #7, name = 'ghc_worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x16d550000)
* frame #0: 0x0000000106acc3c4 matterhorn`__gmpn_mul_1 + 156
frame #1: 0x0000000106ad3cf4 matterhorn`__gmpn_sqr_basecase + 160
frame #2: 0x0000000106ad5e4c matterhorn`__gmpn_toom2_sqr + 552
frame #3: 0x0000000106ad39e8 matterhorn`__gmpn_sqr + 112
frame #4: 0x0000000106ac175c matterhorn`__gmpn_powm + 3464
frame #5: 0x0000000106ad11a4 matterhorn`__gmpz_powm + 2260
(lldb) thread list
Process 91041 stopped
thread #1: tid = 0xaf9997, 0x000000019c7225e4 libsystem_kernel.dylib`__psynch_cvwait + 8, name = 'ghc_worker', queue = 'com.apple.main-thread'
thread #2: tid = 0xaf99a3, 0x000000019c7223e0 libsystem_kernel.dylib`__semwait_signal + 8
thread #3: tid = 0xaf99a4, 0x000000019c727334 libsystem_kernel.dylib`poll + 8
thread #4: tid = 0xaf99a5, 0x000000019c7225e4 libsystem_kernel.dylib`__psynch_cvwait + 8
thread #5: tid = 0xaf99a6, 0x000000019c724e98 libsystem_kernel.dylib`kevent + 8, name = 'ghc_worker'
thread #6: tid = 0xaf99a7, 0x000000019c724e98 libsystem_kernel.dylib`kevent + 8, name = 'ghc_worker'
* thread #7: tid = 0xaf99a8, 0x0000000106acc3c4 matterhorn`__gmpn_mul_1 + 156, name = 'ghc_worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x16d550000)
thread #8: tid = 0xaf99a9, 0x000000019c7225e4 libsystem_kernel.dylib`__psynch_cvwait + 8
thread #9: tid = 0xaf9e12, 0x000000019c7225e4 libsystem_kernel.dylib`__psynch_cvwait + 8
thread #10: tid = 0xaf9e17, 0x000000019c7225e4 libsystem_kernel.dylib`__psynch_cvwait + 8