[GHC] #10231: TMVar - fmap - orElse clashes in ghc 7.8.4

GHC ghc-devs at haskell.org
Fri Apr 3 02:25:41 UTC 2015


#10231: TMVar - fmap - orElse clashes in ghc 7.8.4
-------------------------------------+-------------------------------------
        Reporter:  ran               |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  libraries         |                 Version:  7.8.4
  (other)                            |                Keywords:
      Resolution:                    |            Architecture:  x86_64
Operating System:  Linux             |  (amd64)
 Type of failure:  Incorrect result  |               Test Case:
  at runtime                         |                Blocking:
      Blocked By:                    |  Differential Revisions:
 Related Tickets:                    |
-------------------------------------+-------------------------------------

Comment (by fryguybob):

 When using `unsafePerformIO` to make a global mutable variable like
 `timerTM` in your program you also need to have a `NOINLINE` pragma `{-#
 NOINLINE timerTM #-}` to avoid separate variables due to inlining (see
 [https://wiki.haskell.org/Top_level_mutable_state top level mutable
 state]):

 {{{
 #!haskell
 timerTM :: TMVar ()
 {-# NOINLINE timerTM #-}
 timerTM = unsafePerformIO $ newEmptyTMVarIO

 resetTM :: TMVar ()
 {-# NOINLINE resetTM #-}
 resetTM = unsafePerformIO $ newEmptyTMVarIO
 }}}

 Can you try your test again with this change?

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


More information about the ghc-tickets mailing list