eta icon indicating copy to clipboard operation
eta copied to clipboard

List comprehension hanging

Open jyothsnamutt opened this issue 10 years ago • 3 comments

module Main where

main = do
  print $ boomBangs [13,9]

boomBangs xs = [ if x < 10 then "BOOM!" else "BANG!" | x <- xs, odd x]

Works

module Main where

main = do
  print $ boomBangs [7,9]

boomBangs xs = [ if x < 10 then "BOOM!" else "BANG!" | x <- xs, odd x]

Hangs

module Main where

main = do
  print $ boomBangs [7,13]

boomBangs xs = [ if x < 10 then "BOOM!" else "BANG!" | x <- xs, odd x]

Works

module Main where

main = do
  print $ boomBangs [13,15]

boomBangs xs = [ if x < 10 then "BOOM!" else "BANG!" | x <- xs, odd x]

Hangs

jyothsnamutt avatar Sep 26 '16 13:09 jyothsnamutt

module Main where

main = do
  print $ [adjective ++ " " ++ noun | adjective <- adjectives, noun <- nouns]

nouns = ["hobo","frog","pope"]
adjectives = ["lazy","grouchy","scheming"]

Hangs

jyothsnamutt avatar Sep 26 '16 13:09 jyothsnamutt

After some initial investigation, it looks to be a bug in the thunk updating/blackholing code:

[main] INFO ghcvm.runtime.thunk.Thunk - >> blackHole(1=ghcvm.runtime.stg.StgContext@46147bef, 2=ghcvm.runtime.thunk.StgCAFBlackHole@df2e04c, 3=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.StgConstr - >> getEvaluated()
[main] INFO ghcvm.runtime.stg.StgConstr - << getEvaluated() returns: ghczmprim.ghc.Types$ZCD@59a6acb9.
[main] INFO ghcvm.runtime.stg.StgContext - >> R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.AbstractArgumentStack - >> R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.AbstractArgumentStack - << R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.StgContext - << R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.StgConstr - >> getEvaluated()
[main] INFO ghcvm.runtime.stg.StgConstr - << getEvaluated() returns: ghczmprim.ghc.Types$ZCD@59a6acb9.
[main] INFO ghcvm.runtime.stg.StgContext - >> R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.AbstractArgumentStack - >> R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.AbstractArgumentStack - << R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.StgContext - << R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.StgConstr - >> getEvaluated()
[main] INFO ghcvm.runtime.stg.StgConstr - << getEvaluated() returns: ghczmprim.ghc.Types$ZCD@59a6acb9.
[main] INFO ghcvm.runtime.stg.StgContext - >> R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.AbstractArgumentStack - >> R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.AbstractArgumentStack - << R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)
[main] INFO ghcvm.runtime.stg.StgContext - << R(1=1, 2=ghczmprim.ghc.Types$ZCD@59a6acb9)

That last bit repeats forever.

rahulmutt avatar Sep 27 '16 02:09 rahulmutt

Fixed as of #70

rahulmutt avatar Sep 30 '16 13:09 rahulmutt