From 449b0be44b3bf53c7d817231df3e754278968440 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 16 Oct 2006 11:17:41 +0000 Subject: [PATCH] Fix deadlock on second call to newSession Tracked down by Krasimir Angelov --- compiler/main/GHC.hs | 2 +- compiler/utils/Panic.lhs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index 6295d7d..eabcafc 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -333,7 +333,7 @@ newSession :: GhcMode -> Maybe FilePath -> IO Session newSession mode mb_top_dir = do -- catch ^C main_thread <- myThreadId - putMVar interruptTargetThread [main_thread] + modifyMVar_ interruptTargetThread (return . (main_thread :)) installSignalHandlers dflags0 <- initSysTools mb_top_dir defaultDynFlags diff --git a/compiler/utils/Panic.lhs b/compiler/utils/Panic.lhs index 42bf8b5..eb3ce78 100644 --- a/compiler/utils/Panic.lhs +++ b/compiler/utils/Panic.lhs @@ -40,7 +40,7 @@ import GHC.ConsoleHandler #endif import Control.Exception hiding (try) -import Control.Concurrent ( myThreadId, MVar, ThreadId, withMVar, newEmptyMVar ) +import Control.Concurrent ( myThreadId, MVar, ThreadId, withMVar, newMVar ) import Data.Dynamic import qualified Control.Exception as Exception import Debug.Trace ( trace ) @@ -237,5 +237,5 @@ installSignalHandlers = do {-# NOINLINE interruptTargetThread #-} interruptTargetThread :: MVar [ThreadId] -interruptTargetThread = unsafePerformIO newEmptyMVar +interruptTargetThread = unsafePerformIO (newMVar []) \end{code} -- 1.7.10.4