#5365: Finalizer running prematurely in ghci
---------------------------------+------------------------------------------
Reporter: ekmett | Owner:
Type: bug | Status: new
Priority: normal | Component: GHCi
Version: 7.0.3 | Keywords: finalizers
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
---------------------------------+------------------------------------------
Comment(by ekmett):
I was able to work around this by seq'ing y before adding a finalizer.
Prelude System.Mem.Weak GHC.IO> let x =
let y = "foo" in y `seq` (unsafePerformIO $ addFinalizer y (putStrLn $
"deleted")) `seq` y
Prelude System.Mem.Weak GHC.IO> x
"foo"
Prelude System.Mem.Weak GHC.IO> x
"foo"
So it appears that the finalizer was attached to the thunk that computes
y, and when y was evaluated, I no longer had any reference to the original
thunk.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5365#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs