GHC creates incorrect code which throws <<loop>>
My co-worker and I have spent almost two weeks tracking down this bug. We have finally produced a reasonably small test case... please take a look: https://github.com/yongqli/ghctestcase
Under certain circumstances GHC generates incorrect code which goes into <<loop>>.
When you compile and run the project without profiling and with eager black-holing, it will throw <<loop>> and exit.
If you compile either without eager black-holing or with profiling, it will run correctly.
See setup.hs for further details.
This bug can be delicate to trigger, inlining certain things will prevent it from occurring. However, we've encountered this in production, and it is much harder to work-around in an actual project. We've had to resort to inlining every function in the affected module, which slows down compilation considerably.
We've found that this bug triggers on 7.10.1 and 7.8.4. The test case will only compile on 7.10.1.
Please let me know if there are any questions.