[GHC] #15143: Passing an IO value through several functions results in program hanging.

GHC ghc-devs at haskell.org
Sat May 12 01:02:09 UTC 2018


#15143: Passing an IO value through several functions results in program hanging.
-------------------------------------+-------------------------------------
           Reporter:  Burtannia      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.4.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Runtime
  Unknown/Multiple                   |  performance bug
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I came across this rather interesting bug while writing my dissertation.

 The following function takes an IO Obs and if it is an observable of
 time (ObsTime) it increments the contained Int. Otherwise it leaves it
 unchanged:

 {{{#!hs
 incTime :: IO Obs -> IO Obs
 incTime o = do
     obs <- o
     case obs of
         ObsTime t -> return $ ObsTime (t+1)
         _         -> o
 }}}

 The case for ObsTime works as expected however, the wildcard case gets
 progressively slower the more times a value is passed through. At 30
 iterations I waited 10 seconds before aborting execution, the function had
 still not returned.

 This issue does not occur with the following change to the wildcard case:
 {{{#!hs
 _ -> return obs
 }}}

 This issue occurs both in GHCi and after compiling with GHC.

 I have attached a file with the necessary code to demonstrate the issue.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15143>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list