From 1d35a9fdaef6d29e5ac19c2c0318d8e86b5070b2 Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 4 Jun 2001 16:34:19 +0000 Subject: [PATCH] [project @ 2001-06-04 16:34:19 by simonmar] Add test for Manuel's finalizer bug. --- ghc/tests/concurrent/should_run/conc031.hs | 30 ++++++++++++++++++++++++ ghc/tests/concurrent/should_run/conc031.stdout | 2 ++ 2 files changed, 32 insertions(+) create mode 100644 ghc/tests/concurrent/should_run/conc031.hs create mode 100644 ghc/tests/concurrent/should_run/conc031.stdout diff --git a/ghc/tests/concurrent/should_run/conc031.hs b/ghc/tests/concurrent/should_run/conc031.hs new file mode 100644 index 0000000..c992d57 --- /dev/null +++ b/ghc/tests/concurrent/should_run/conc031.hs @@ -0,0 +1,30 @@ +import Concurrent +import Exception +import IOExts +import Weak + +data P = P (MVar Bool) + +-- Bug reported by Manuel Chakravarty, namely that we weren't checking +-- for runnable finalizers before declaring that the program is +-- deadlocked. + +main = do +-- gcThread -- with this thread enabled, no error + mv <- newEmptyMVar + let p = P mv + addFinalizer p (set p) + takeMVar mv >>= print + putStrLn "End." + where + set (P mv) = putMVar mv True + -- + -- this is just to demonstrate that it is only about the GC timing + -- + gcThread = forkIO $ let gc = do + putStrLn "delay" + threadDelay 100000 + putStrLn "gc" + performGC + gc + in gc diff --git a/ghc/tests/concurrent/should_run/conc031.stdout b/ghc/tests/concurrent/should_run/conc031.stdout new file mode 100644 index 0000000..8d45abf --- /dev/null +++ b/ghc/tests/concurrent/should_run/conc031.stdout @@ -0,0 +1,2 @@ +True +End. -- 1.7.10.4