Skip to content

Sporadic segfaults at pustCostCentre with prof+dyn GHC

Summary

On an experimental branch: https://gitlab.haskell.org/wavewave/ghc/-/tree/wavewave/ghc_p_dyn?ref_type=heads (both GHC and Cabal modified) I am testing profiled_ghc flavour without no_dynamic_ghc, i.e. GHC with p_dyn flavour. and it was successful in building a private mega-project. But sometimes, sporadically, segfaults happened with the following backtrace (from macOS diagnostics report). Until now, I experienced this only with -j option on, so it's probably a concurrency bug.

Note: The change made in the experimental branch is mainly about building and linking, and RTS is as is except GHC built with both profiling and dynamic on.

...
Thread 13 Crashed:: ghc_worker
0   ???                           	       0x103a7186c pushCostCentre + 56
1   ???                           	       0x103a7c8b4 schedule + 1164
2   ???                           	       0x103a7c8b4 schedule + 1164
3   libsystem_pthread.dylib       	       0x18be2ce3c thread_start + 8
...
Thread 13 crashed with ARM Thread State (64-bit):
    x0: 0x00000070c576f800   x1: 0x000000010c0b74e0   x2: 0x0000007130520120   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x00000000000000a0   x6: 0x0000000000000000   x7: 0x0000007026f1e888
    x8: 0x0000000000617265   x9: 0x0000000000000000  x10: 0x000000000000000a  x11: 0x0000000000000000
   x12: 0x0000000000000000  x13: 0x0000000000000000  x14: 0x0000000000000000  x15: 0x0000007026f1e9a2
   x16: 0x0000000103a71834  x17: 0x000000010c0b74e0  x18: 0x0000000000000000  x19: 0x000000010c0b74e0
   x20: 0x0000007115499e10  x21: 0x00000070c576f800  x22: 0x0000007026f1e9a2  x23: 0x00000070c576f8e0
   x24: 0x0000000000000000  x25: 0x00000070021b8a99  x26: 0x00000070021b8a99  x27: 0x0000007122f80903
   x28: 0x00000071154920d0   fp: 0x000000016d722d80   lr: 0x000000010af4a768
    sp: 0x000000016d722d20   pc: 0x0000000103a7186c cpsr: 0x80001000
   far: 0x0000000000617265  esr: 0x92000006 (Data Abort) byte read Translation fault

Although this is not a current GHC HEAD problem (as p_dyn is not supported), but it probably revealed a bug in profiling code and that may happen in static profiling, so I report it to track this issue.

Steps to reproduce

Use https://gitlab.haskell.org/wavewave/ghc/-/tree/wavewave/ghc_p_dyn?ref_type=heads , build GHC with --flavour=perf+profiled_ghc and build a big project and wait for this happening. The chances are not very high though, and probably correlated to the size of the target project.

I will update this if I can find a minimal example.

Expected behavior

Segfault should not happen in any case.

Environment

  • GHC version used: custom GHC version (wavewave/ghc_p_dyn branch 50b4995), on top of GHC 9.9.20240131 (38c3afb6)

Optional:

  • Operating System: macOS Sonoma 14.3
  • System Architecture: Apple M1 Max
Edited by Ian-Woo Kim
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information