Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,867
    • Issues 4,867
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 457
    • Merge requests 457
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13429
Closed
Open
Created Mar 16, 2017 by Alexey Kuleshevich@lehinsReporter

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
evaluated by: Main.main,\r\n called from Main.CAF\r\n --> evaluated by: Loop.toKernel.\\,\r\n called from Data.Vector.Fusion.Util.>>=,\r\n called from Loop.toKernel,\r\n called from Main.main,\r\n called from Main.CAF\r\n --> evaluated by: Data.Vector.Fusion.Util.>>=,\r\n called from Loop.toKernel,\r\n called from Main.main,\r\n called from Main.CAF\r\n*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace: \r\n Main.CAF\r\nmain: <>\r\n}}}\r\n\r\n\r\nAt 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.\r\n\r\nWorth noting that sometimes, when recompilation of only the `main.hs` file is enforced, program starts to work as expected. Here is an example:\r\n\r\n\r\n{{{\r\n$ stack --resolver ghc-7.10.3 exec --package vector-0.11.0.0 --package primitive-0.6.1.0 -- ghc -O1 main.hs && ./main\r\n[1 of 2] Compiling Loop ( Loop.hs, Loop.o )\r\n[2 of 2] Compiling Main ( main.hs, main.o )\r\nLinking main ...\r\nmain: <>\r\n$ touch main.hs\r\n$ stack --resolver ghc-7.10.3 exec --package vector-0.11.0.0 --package primitive-0.6.1.0 -- ghc -O1 main.hs && ./main\r\n[2 of 2] Compiling Main ( main.hs, main.o )\r\nLinking main ...\r\n\r\n}}}\r\n","type_of_failure":"IncorrectResultAtRuntime","blocking":[]} -->
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking