GHC 9.2 alpha 2 Darwin apple silicon: SIGSEGV with GHCi (Potential GC issue)
Summary
When launching GHCi
and using it for a few seconds results in a SIGSEGV
being raised.
Steps to reproduce
Launch GHCi:
matthew@matthews-air ~/D/g/i/bin> ./ghc-stage2 --interactive
And use it, very shortly after you should see a SIGSEGV
. When this occurs seems to happen randomly:
GHCi, version 9.2.0.20210422: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/matthew/.dotfiles/files/ghci
λ❯ a = 1
a :: Num a => a
(0.01 secs, 70,088 bytes)
λ❯ b = 2
b :: Num a => a
(0.00 secs, 70,080 bytes)
λ❯ c = 3
c :: Num a => a
(0.00 secs, 70,088 bytes)
λ❯ d = 4
d :: Num a => a
(0.00 secs, 70,080 bytes)
λ❯ a = [1,2,3,4]
a :: Num a => [a]
(0.00 secs, 70,088 bytes)
λ❯ a
fish: Job 1, './ghc-stage2 --interactive' terminated by signal SIGSEGV (Address boundary error)
And another run:
GHCi, version 9.2.0.20210422: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/matthew/.dotfiles/files/ghci
λ❯ (+) <$> [1,2,3] <*> [2,3]
fish: Job 1, './ghc-stage2 --interactive' terminated by signal SIGSEGV (Address boundary error)
Expected behavior
Not to crash
Environment
- GHC version used: The Glorious Glasgow Haskell Compilation System, version 9.2.0.20210422
Optional:
- Operating System: MacOS 11.4
- System Architecture: aarch64 (apple silicon)
I've also managed to capture a stack trace of the issue with lldb
:
λ❯ a libHSrts_thr_l-ghc9.2.0.20210422.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 8523 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1ed03b100870018)
frame #0: 0x0000000109ec7338 libHSrts_thr_l-ghc9.2.0.20210422.dylib`evacuate1 [inlined] get_itbl(c=<unavailable>) at ClosureMacros.h:87:31 [opt]
84 EXTERN_INLINE const StgInfoTable *get_itbl(const StgClosure *c);
85 EXTERN_INLINE const StgInfoTable *get_itbl(const StgClosure *c)
86 {
-> 87 return INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info));
88 }
89
90 EXTERN_INLINE const StgRetInfoTable *get_ret_itbl(const StgClosure *c);
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1ed03b100870018)
* frame #0: 0x0000000109ec7338 libHSrts_thr_l-ghc9.2.0.20210422.dylib`evacuate1 [inlined] get_itbl(c=<unavailable>) at ClosureMacros.h:87:31 [opt]
frame #1: 0x0000000109ec7338 libHSrts_thr_l-ghc9.2.0.20210422.dylib`evacuate1(p=<unavailable>) at Evac.c:703 [opt]
frame #2: 0x0000000109ed6b90 libHSrts_thr_l-ghc9.2.0.20210422.dylib`scavenge_block1(bd=<unavailable>) at Scav.c:601:13 [opt]
frame #3: 0x0000000109ed6330 libHSrts_thr_l-ghc9.2.0.20210422.dylib`scavenge_loop1 [inlined] scavenge_find_work at Scav.c:0:24 [opt]
frame #4: 0x0000000109ed630c libHSrts_thr_l-ghc9.2.0.20210422.dylib`scavenge_loop1 at Scav.c:2178 [opt]
frame #5: 0x0000000109ecc5b8 libHSrts_thr_l-ghc9.2.0.20210422.dylib`scavenge_until_all_done at GC.c:1295:13 [opt]
frame #6: 0x0000000109ecb7a4 libHSrts_thr_l-ghc9.2.0.20210422.dylib`GarbageCollect(collect_gen=<unavailable>, do_heap_census=<unavailable>, is_overflow_gc=false, deadlock_detect=<unavailable>, gc_type=<unavailable>, cap=0x0000000109f1f640, idle_cap=0x000000010b504080) at GC.c:538:3 [opt]
frame #7: 0x0000000109eb9a4c libHSrts_thr_l-ghc9.2.0.20210422.dylib`scheduleDoGC(pcap=0x000000016fdfeef0, task=0x000000010b104ca0, force_major=false, is_overflow_gc=true, deadlock_detect=false) at Schedule.c:1886:5 [opt]
frame #8: 0x0000000109eb8ffc libHSrts_thr_l-ghc9.2.0.20210422.dylib`schedule(initialCapability=<unavailable>, task=0x000000010b104ca0) at Schedule.c:579:7 [opt]
frame #9: 0x0000000109eb85ec libHSrts_thr_l-ghc9.2.0.20210422.dylib`scheduleWaitThread(tso=0x0000007000406ce8, ret=<unavailable>, pcap=0x000000016fdfef90) at Schedule.c:2651:11 [opt]
frame #10: 0x0000000109eb2490 libHSrts_thr_l-ghc9.2.0.20210422.dylib`rts_evalLazyIO(cap=<unavailable>, p=<unavailable>, ret=<unavailable>) at RtsAPI.c:566:5 [opt] [artificial]
frame #11: 0x0000000109eb4d08 libHSrts_thr_l-ghc9.2.0.20210422.dylib`hs_main(argc=3, argv=0x000000016fdff0e0, main_closure=<unavailable>, rts_config=<unavailable>) at RtsMain.c:72:9 [opt]
frame #12: 0x000000010017c1fc ghc-stage2`main + 120
frame #13: 0x0000000199e85450 libdyld.dylib`start + 4
(lldb)
From this, it looks like the problem is with the garbage collector.