From: simonmar Date: Fri, 20 Aug 2004 15:02:40 +0000 (+0000) Subject: [project @ 2004-08-20 15:02:40 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~1705 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=fcbc4b62830f07dc13a820eb07b0d58317a173e4 [project @ 2004-08-20 15:02:40 by simonmar] Hack to work around bug on Windows reported by Levent Erkok : Prelude> let x=x in x *** Exception: <> Prelude> 3 Fail: thread blocked indefinitely Details in the comment. MERGE TO STABLE --- diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 9a885ab..98b653d 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.174 2004/08/16 09:53:57 simonpj Exp $ +-- $Id: InteractiveUI.hs,v 1.175 2004/08/20 15:02:40 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -68,6 +68,7 @@ import System.Directory import System.IO as IO import Data.Char import Control.Monad as Monad +import Foreign.StablePtr ( newStablePtr ) import GHC.Exts ( unsafeCoerce# ) @@ -159,6 +160,18 @@ interactiveUI srcs maybe_expr = do cmstate <- cmInit Interactive dflags; + -- HACK! If we happen to get into an infinite loop (eg the user + -- types 'let x=x in x' at the prompt), then the thread will block + -- on a blackhole, and become unreachable during GC. The GC will + -- detect that it is unreachable and send it the NonTermination + -- exception. However, since the thread is unreachable, everything + -- it refers to might be finalized, including the standard Handles. + -- This sounds like a bug, but we don't have a good solution right + -- now. + newStablePtr stdin + newStablePtr stdout + newStablePtr stderr + hFlush stdout hSetBuffering stdout NoBuffering