> [...]
> > -davenant:stalk> ./nettlestalk 
> > foo
> > Segmentation fault (core dumped)
> 
> I'm using 4.04.19990916-2 and it doesn't coredump, but shows the same
> deadlock error, you mentioned in the other mail:
> 
> [509]$ ./nettlestalk
> foo
> nettlestalk: fatal error: No threads to run!  Deadlock?

This is due to a locking problem with our I/O library.  Basically, if the
program calls trace while writing to stdout (eg. using putStr), then a
deadlock occurs.  The reason is that trace tries to write to stderr, which
attempts to open stdout (in order to flush it), but stdout is already locked
because we're in the middle of doing a putStr.

Workaround: seq stderr before doing anything.  The problem will still occur
if you attempt to trace while writing to stderr, so "don't do that".  We
have plans to fix the problem properly, but it involves a partial redesign
of our I/O library.

A patch for Michael's example program is enclosed...

Cheers,
        Simon

*** server.hs~  Mon Dec  6 11:38:32 1999
--- server.hs   Mon Dec  6 11:41:26 1999
***************
*** 18,23 ****
--- 18,24 ----
  --
  -- $Id: server.hs,v 1.7 1999/12/05 16:29:04 ian Exp $
  
+ import IO
  import Int
  import FiniteMap
  import IOExts
***************
*** 269,275 ****
        inXSM $ putStr $ "game state: "++(show gs)++"\n"
  
  main :: IO ()
! main = do
                putStr "foo\n"
                putStr (show r)
        where
--- 270,277 ----
        inXSM $ putStr $ "game state: "++(show gs)++"\n"
  
  main :: IO ()
! main =  seq stderr $
!       do
                putStr "foo\n"
                putStr (show r)
        where

Reply via email to