[project @ 2001-06-04 16:34:19 by simonmar]
authorsimonmar <unknown>
Mon, 4 Jun 2001 16:34:19 +0000 (16:34 +0000)
committersimonmar <unknown>
Mon, 4 Jun 2001 16:34:19 +0000 (16:34 +0000)
Add test for Manuel's finalizer bug.

ghc/tests/concurrent/should_run/conc031.hs [new file with mode: 0644]
ghc/tests/concurrent/should_run/conc031.stdout [new file with mode: 0644]

diff --git a/ghc/tests/concurrent/should_run/conc031.hs b/ghc/tests/concurrent/should_run/conc031.hs
new file mode 100644 (file)
index 0000000..c992d57
--- /dev/null
@@ -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 (file)
index 0000000..8d45abf
--- /dev/null
@@ -0,0 +1,2 @@
+True
+End.