RTS STM Segmentation fault on Linux/MacOS
Summary
Compiling and running the attached project segfaults on both Linux and MacOs on GHC 8.0 through 8.6. I tried minimising the code as much as possible, but I've reached a point where even inlining terms masks the segfault. Also, not using STM retry
masks the segfault. Also, the code has to be spread across two modules, the segfault doesn't occur if everything is in e.g. Main.hs.
Sometimes, the RTS manages to shut down before a hard crash, i.e.:
stm-bug-0.1.0.0: unregistering (local file changes: src/Lib.hs)
stm-bug-0.1.0.0: build (lib + exe)
Preprocessing library for stm-bug-0.1.0.0..
Building library for stm-bug-0.1.0.0..
[2 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Lib.o )
Preprocessing executable 'stm-bug-exe' for stm-bug-0.1.0.0..
Building executable 'stm-bug-exe' for stm-bug-0.1.0.0..
[1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/stm-bug-exe/stm-bug-exe-tmp/Main.o ) [Lib changed]
Linking .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/stm-bug-exe/stm-bug-exe ...
stm-bug-0.1.0.0: copy/register
Installing library in /home/phil/Projects/stm-bug/.stack-work/install/x86_64-linux/lts-13.26/8.6.5/lib/x86_64-linux-ghc-8.6.5/stm-bug-0.1.0.0-FnTyJxtuwWMDN9Vt5S3LQp
Installing executable stm-bug-exe in /home/phil/Projects/stm-bug/.stack-work/install/x86_64-linux/lts-13.26/8.6.5/bin
Registering library for stm-bug-0.1.0.0..
stm-bug-exe: internal error: evacuate: strange closure type 9435472
(GHC version 8.6.5 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Aborted (core dumped)
Other error messages while isolating the test case where included references to strange closure type 4325519
, stg_ap_p_ret
, and stg_END_STM_WATCH_QUEUE_closure
.
Steps to reproduce
stack build && stack exec stm-bug-exe
Expected behavior
Not segfault.
Environment
- GHC version used: 8.0.* - 8.6.* (didn't test with 7.*)
- gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10), Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Optional:
- Operating System: Linux, MacOS, maybe Windows
- System Architecture: