[GHC] #15349: fixST is a bit wrong

GHC ghc-devs at haskell.org
Fri Jul 6 18:05:32 UTC 2018


#15349: fixST is a bit wrong
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Core           |           Version:  8.5
  Libraries                          |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Incorrect result
  Unknown/Multiple                   |  at runtime
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Lazy blackholing lets some `ST` calculations complete that shouldn't.

 {{{#!hs
 import Control.Monad.ST.Strict
 import Control.Monad.Fix
 import Data.STRef

 foo :: ST s Int
 foo = do
   ref <- newSTRef True
   mfix $ \res -> do
     x <- readSTRef ref
     if x
       then do
         writeSTRef ref False
         return $! (res + 5)
       else return 10

 main = print $ runST foo
 }}}

 When this is compiled with `-O -feager-blackholing`, it produces a
 `<<loop>>` exception as expected. When it's compiled with `-O0` or with
 `-fno-eager-blackholing`, it prints `15`.

 Should we reimplement `fixST` to do something like what `fixIO` does? Or
 should we consider this sometimes-lost bottom tolerable?

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


More information about the ghc-tickets mailing list