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

GHC ghc-devs at haskell.org
Sat May 12 01:08:20 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
      Resolution:                    |             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:                    |
-------------------------------------+-------------------------------------
Description changed by Burtannia:

Old description:

> 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.
>
> It might also be worth mentioning that I've had the issue on Ubuntu (GHC
> 8.4.2 & 7.10.3) and Windows 7 (GHC 8.0.2). So it doesn't seem to be OS
> specific or caused by a recent change to GHC.
>
> I have attached a file with the necessary code to demonstrate the issue.

New description:

 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 (with and
 without -O2).

 It might also be worth mentioning that I've had the issue on Ubuntu (GHC
 8.4.2 & 7.10.3) and Windows 7 (GHC 8.0.2). So it doesn't seem to be OS
 specific or caused by a recent change to GHC.

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

--

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


More information about the ghc-tickets mailing list