Finalizer running prematurely in ghci
|Reported by:||ekmett||Owned by:||simonmar|
|Type of failure:||Incorrect result at runtime||Test Case:|
|Related Tickets:||Differential Revisions:|
I have been building a library for doing hash consing, but it seemed to incorrectly finalize references to live entries in the hash cons table when I use it from ghci.
I've distilled the problem to the following test case.
Prelude System.Mem.Weak GHC.IO> let x = let y = "foo" in (unsafePerformIO $ addFinalizer y (putStrLn "deleted")) `seq` y Prelude System.Mem.Weak GHC.IO> x "foo" deleted Prelude System.Mem.Weak GHC.IO> x "foo"