There's another problem with Simon's patch I haven't been able to pin down: if you run the example, interrupt it at the right point and type another expression, the finalizers run, but the expression is lost.
I can get it to fail another way too: main = do p <- mallocBytes 64 newForeignPtr p (print x) print x where x = sum [1..10000] Can't believe I didn't realise this kind of thing might be a problem before... guess I was too fixated on the other issues. Anyway, it really needs someone who is familiar with the Hugs backend to comment on whether either of these problems are fixable or not. This one I think you could trigger by using the unsafePerformIO->C->Haskell sequence too. Cheers, Simon
On Thu, Oct 17, 2002 at 10:09:06AM +0100, Simon Marlow wrote:
There's another problem with Simon's patch I haven't been able to pin down: if you run the example, interrupt it at the right point and type another expression, the finalizers run, but the expression is lost.
I can get it to fail another way too:
main = do p <- mallocBytes 64 newForeignPtr p (print x) print x where x = sum [1..10000]
Can't believe I didn't realise this kind of thing might be a problem before... guess I was too fixated on the other issues. Anyway, it really needs someone who is familiar with the Hugs backend to comment on whether either of these problems are fixable or not.
I can fix mine, though not yours: it's necessary to wrap runFinalizers() in push(n) ... drop(), so the garbage collector will see n.
SimonM:
I can get it to fail another way too:
main = do p <- mallocBytes 64 newForeignPtr p (print x) print x where x = sum [1..10000]
The problem is probably this shared mutable variable used behind the scenes in the implementation of the numeric show code (hugs98/src/printer.c) static Cell out; /* GC'd var used by printer code */ [It's also used if you use the -u flag to use Hugs' builtin printer instead of the Show function - but I don't think anyone does that anymore and we could probably kill that code without anyone noticing (???). (Unless, does Hood or some such use it?)] I think all the functions affected return void so it'd be easy to replace the global variable with a local which is threaded through that set of functions. -- Alastair
participants (3)
-
Alastair Reid -
Ross Paterson -
Simon Marlow