[Haskell-cafe] ForeignPtrs with liveness dependencies
ekarttun at cs.helsinki.fi
Tue Jul 26 11:48:31 EDT 2005
"Simon Marlow" <simonmar at microsoft.com> writes:
> No, unfortunately not. You have foo's finalizer which refers to bar via
> a touchForeignPtr. If both foo and bar are unreachable (references from
> finalizers don't count), then both foo and bar's finalizers will be
> started together, and may run in any order.
I didn't realize the "references from finalizers don't count" rule.
What would happen if the finalizer of foo would resurrect bar after
bar's finalizer has been run?
> So touchForeignPtr does only one thing: it expresses the precise
> relationship "bar is alive if foo is alive". If both are not alive,
> then both finalizers can run, in any order.
So reference counting the objects is the solution?
> I realise this is very subtle. By all means suggest improvements to the
Mentioning that references from finalizers don't count could help
someone not to repeat my mistakes.
- Einar Karttunen
More information about the Haskell-Cafe