Optimizer produces Core with an infinite <<loop>>
While using vector package to implement convolution and supplying -O1
or -02
to ghc compilation results in core with an infinite loop. In order to trigger this behavior at least two modules is required. Attached is the minimal setup that I could come up with, that demonstrates the issue. Here is the stack trace:
$ stack --install-ghc --resolver lts-8.3 exec -- ghc -O1 -prof -fprof-auto main.hs && ./main +RTS -xc
[1 of 2] Compiling Loop ( Loop.hs, Loop.o )
[2 of 2] Compiling Main ( main.hs, main.o )
Linking main ...
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
Main.CAF
--> evaluated by: Main.main,
called from Main.CAF
--> evaluated by: Loop.toKernel.\,
called from Data.Vector.Fusion.Util.>>=,
called from Loop.toKernel,
called from Main.main,
called from Main.CAF
--> evaluated by: Data.Vector.Fusion.Util.>>=,
called from Loop.toKernel,
called from Main.main,
called from Main.CAF
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
Main.CAF
main: <<loop>>
At first I though that it might be a bug in a vector package, which is still a possibility, but since I was not able to observe that issue with ghc-7.8.4, I decided to open an ticket here. I tested attached code with all of subsequent released ghc versions (7.10.1 - 8.0.2), which resulted in the infinite loop.
Worth noting that sometimes, when recompilation of only the main.hs
file is enforced, program starts to work as expected. Here is an example:
$ stack --resolver ghc-7.10.3 exec --package vector-0.11.0.0 --package primitive-0.6.1.0 -- ghc -O1 main.hs && ./main
[1 of 2] Compiling Loop ( Loop.hs, Loop.o )
[2 of 2] Compiling Main ( main.hs, main.o )
Linking main ...
main: <<loop>>
$ touch main.hs
$ stack --resolver ghc-7.10.3 exec --package vector-0.11.0.0 --package primitive-0.6.1.0 -- ghc -O1 main.hs && ./main
[2 of 2] Compiling Main ( main.hs, main.o )
Linking main ...
<Image 1x1>
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.2 |
Type | Bug |
TypeOfFailure | IncorrectResultAtRuntime |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |