[GHC] #11760: runST with lazy blackholing breaks referential transparency

GHC ghc-devs at haskell.org
Mon Apr 11 12:38:55 UTC 2016


#11760: runST with lazy blackholing breaks referential transparency
-------------------------------------+-------------------------------------
        Reporter:  Yuras             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonmar):

 Wow. Great bug. This should not happen.

 I believe the problem is specific to the lazy ST monad
 (`Control.Monad.ST.Lazy`), but your example relies on this so it's hard to
 test the theory.

 What happens is that the top-level runST thunk gets updated with `(x :
 xs)` where `xs` is itself a lazy ST computation that refers to mutable
 state.  At this point it is possible for two threads to evaluate the inner
 thunk and get different results.

 We could use `noDuplicate#` in the lazy ST monad which should prevent
 this, but it will make lazy ST much more expensive.  Maybe that's ok.

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


More information about the ghc-tickets mailing list