Skip to content

Consistent segfault when compiled program is executed

Current status

%8.8.2 will ship with a fix avoiding this issue for the uses of unsafeCoerce in 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.

Summary

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 ByteString/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 -O1 or -O2 is necessary.

Expected behavior

Executable should exit successfully

Environment

  • GHC version used: GHC-8.4.4 through GHC-8.6.5

Optional:

  • Operating System: Ubuntu 18.04 LTS
  • System Architecture: x86_64
Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information