cvs commit: hugs98/src builtin.h dirprim.c iomonad.c timeprim.c

Ross Paterson ross at haskell.org
Thu Sep 30 12:49:08 EDT 2004


ross        2004/09/30 09:49:07 PDT

  Modified files:
    src                  builtin.h dirprim.c iomonad.c timeprim.c 
  Log:
  Fix for bug reported by Henk-Jan van Tuyl, in which the following
  corrupts the heap if "foo" isn't found:
  
  	import System.IO
  
  	main :: IO ()
  	main = do
  		h1 <- openFile "/usr/dict/words" ReadMode
  		let fileName = "foo"
  		h2 <- openFile fileName ReadMode
  		return ()
  
  The second openFile triggers a GC, which corrupts the indirection to
  fileName used by the error report.
  
  The bug has been there a long time, but has emerged now because we cut
  the starting size of the handle table (to make rare bugs more common).
  
  Today I learned that
  
  	Cell x = ...;
  	<possible GC>
  	... x ...
  
  is unsafe if x could refer to an indirection, even with conservative GC,
  even if there are copies of x on the stack.
  
  The fix is ugly (use a Cell * instead) but I couldn't think of anything
  better.
  
  Revision  Changes    Path
  1.7       +3 -3      hugs98/src/builtin.h
  1.19      +76 -76    hugs98/src/dirprim.c
  1.80      +130 -130  hugs98/src/iomonad.c
  1.12      +16 -16    hugs98/src/timeprim.c


More information about the Cvs-hugs mailing list