Finalizers and FFI
Simon Marlow
simonmar at microsoft.com
Mon Jun 14 11:29:28 EDT 2004
To clarify some of the points in this discussion:
Alastair is right in that the finalizer thread isn't necessarily run to
completion if the main thread exits. GHC does run any outstanding
finalizers at the end of the program, but it doesn't necessarily
complete any existing finalizer threads that have already started.
This is clearly inconsistent, and we were planning to make it consistent
by not guaranteeing to run finalizers at program exit at all. There are
good reasons (at least, good justifications) for this[1].
If your finalizer results in <<loop>>, it is probably because you tried
to write to stdout in the finalizer, and the finalizer ran after stdout
had already been finalized. Try calling something lower-level if you
want to do some output from a finalizer. We don't implement any kind of
finalizer ordering or dependencies between finalizers. There are good
reasons for this[1] :-)
Cheers,
Simon
[1] http://www.hpl.hp.com/techreports/2002/HPL-2002-335.html, especially
Appendix A.
More information about the Glasgow-haskell-users
mailing list