The Revenge of Finalizers

Ross Paterson ross at
Wed Oct 16 20:28:14 EDT 2002

> [...] Can we easily identify which are the unsafe places and fix them?

> Look at all prims with types in IO.  Look at what data structures they
> touch.  Check if there are accesses to that data structure 'both
> sides' of a call to eval (there may be a few functions which invoke
> eval so watch for them).  Check if any such accesses break data
> structure invariants.

> Since this can affect Hugs as it stands (when you use unsafePerformIO),
> would you mind taking a look?

There are over 200 calls to eval() in Hugs.  Almost all of them look OK
on a cursory scan.  As Alastair said, most are at the start of primitives,
and Hugs uses its stack and local variables a lot.  But there's an unsafe
use in evalName(), and I don't understand the mutual recursion between
eval() and run().

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.

More information about the FFI mailing list