Memory Corruption (strange closure type)
I've been encountering corruption of memory in a library of mine that uses some of GHC's more recent features (levity polymorphism and unboxed sums). The library is
packed, and it's source code can be found on my github. But, more relevant to this issue is the minimal reproducible example I've put together here: https://github.com/andrewthad/corrupted-memory-example
It's still a bit larger than I'd like it to be, and if no one has any insights into this, I can keep whittling it down to make it more minimal. Here's how to run it:
git clone https://github.com/andrewthad/corrupted-memory-example cd corrupted-memory-example cabal new-build --enable-tests test ./dist-newstyle/build/corrupted-memory-example-0.1/build/test/test
This consistently crashes with:
test: internal error: evacuate(static): strange closure type 16648 (GHC version 8.4.1 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Additional information: This issue can be reproduced using GHC 8.2.2, GHC 8.4.1, and GHC HEAD. This project cannot be built with GHC 8.0.2 and earlier since it uses unboxed sums. Building this project with either
cabal new-build and then running the test causes the same crash. However, building it with plain old GHC and then running it does not. This is really weird, since there aren't any GHC options in the cabal file that should affect this. In the original library, I have a bunch of tests that use the parsers
any in a variety of situations, and none of them every trigger this crash except for the ones where I stick a
Parser inside of a
Trie. This project does a lot of manual passing of state tokens, but I believe all of these uses to be correct (mostly because of the extensive tests in the original repo, but I've also spent a lot of time just looking at the code to figure out if this was something on my end).
Let me know if the example is too big. I can spend some more time shrinking it further, but I wanted to go ahead and get it up here.