Skip to content

GHC 9.6 segfault at `updateThunk + 392`

Summary

I've found a very reliable segfault with haskell-language-server and GHC 9.6. I've reported it to the haskell-language-server repository here but I think it may be a GHC bug, so I'm filing an issue here as well.

Steps to reproduce

  1. Open the editor and let haskell-language-server load our Haskell backend (~5700 modules). Unfortunately, our codebase is proprietary and can't be shared. I'll see if I can reproduce on an open-source codebase.
  2. Make an edit and save the file. I typically add a definition like foo :: (); foo = ().
  3. haskell-language-server segfaults immediately.

Expected behaviour

haskell-language-server should reindex and continue to provide language intelligence.

Actual behaviour

haskell-language-server segfaults and exits unceremoniously.

Debug information

There are two bits of good news with this bug. The first is that on macOS, a crash report is automatically written to ~/Library/Logs/DiagnosticReports. The other is that it is very consistently reproducible. Here is the relevant excerpt from the crash report:

Crashed Thread:        32  ghc_worker

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000040
Exception Codes:       0x0000000000000001, 0x0000000000000040

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [61666]

VM Region Info: 0x40 is not in any region.  Bytes before following region: 105553518919616
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

...

Thread 32 Crashed:: ghc_worker
0   ???                           	       0x1046a3bd0 updateThunk + 392
1   ???                           	       0x10469caa8 schedule + 1188
2   ???                           	       0x10469caa8 schedule + 1188
3   libsystem_pthread.dylib       	       0x18a64ada0 thread_start + 8

It seems to always crash at updateThunk + 392.

Environment

  • GHC version used: 9.6.1

Optional:

  • Operating System: macOS 13
  • System Architecture: aarch64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information