On 03/04/2012 21:40, Paul Liu wrote:
It seems to violate the claim that "all finalizers are run exactly
once" mentioned in the weak pointer paper. Is there any reason not to
enforce this?

GHC does do a GC before the program quits, but it doesn't wait for all the finalizers to finish. It turns out to be difficult to do that: the runtime doesn't know the difference between a finalizer thread and an ordinary thread, and we don't normally wait for ordinary threads to finish before terminating the program. What about blocked finalizers? What if the finalizers create more finalizers? It's all a bit of a swamp. So now we just don't guarantee that (Haskell) finalizers run before program exit; if you want guaranteed execution then you can use C finalizers.

Some of the motivation for this change comes from Hans Boehm's seminal paper on finalizers:

http://www.hpl.hp.com/techreports/2002/HPL-2002-335.html

Cheers,
        Simon

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to