Consistent segfault when compiled program is executed
%8.8.2 will ship with a fix avoiding this issue for the uses of
Data.Typeable.Internal. However, it is still possible for the crash to manifest in user code using
unsafeCoerce. The underlying cause won't be fixed until %8.10.1, with !1869 (closed) .
If you are a user seeing this issue, you are advised to factor the
unsafeCoerce application into a separate binding with a
NOINLINE pragma to ensure that the simplifier cannot float out the coerced value outside of the
case alternatives where the coercion is valid.
The bug is very straightforward: compiled program results in a segfault when executed. I could not make it reproducible without a
bytestring dependency, but the couple places where
ShortByteStrings are created as completely empty.
Steps to reproduce
Here is a github repo that contains a minimal (as much as I could make it) project that triggers a bug. Just in case, source files are also attached to this ticket.
In order to reproduce using the attached files:
$ ghc -fforce-recomp -O1 Main.hs Complex.hs Sample.hs -o trigger-segfault && ./trigger-segfault
Compiling without optimizations (
-O0) does not trigger the bug, so
-O2 is necessary.
Executable should exit successfully
- GHC version used: GHC-8.4.4 through GHC-8.6.5
- Operating System: Ubuntu 18.04 LTS
- System Architecture: x86_64