When cleaning up the finalizers of a domain, do it in a way that reduces the chance...
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 7 May 2012 14:31:22 +0000 (11:31 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 7 May 2012 14:39:02 +0000 (11:39 -0300)
commitf6ff534aa3f86a723996256ecae14c8758621daf
tree929e52a06d1709465e374f6d19af3d83f6953f88
parent3ff9c8821e14d092b2b9534b24d449338dbbad61
When cleaning up the finalizers of a domain, do it in a way that reduces the chance of leftover objects.

* gc.c (finalize_domain_objects): When cleaning up a domain, we run two kinds of finalizers,
those that have already been queued and those for objects that remain alive.

A common problem we need to deal is that some finalizers allocate other finalizable objects
when doing seeminly trivial operations such as String.IndexOf - which might require the Thread
object of the finalizer thread to be instantiated.

We handle those new objects by draining the registered finalizers set until none shows up. This fails
if we run the queued finalizers after that.

The order onto which finalizers are run on domain unload is unspecified and the new behavior can
be argued to be more natural.
mono/metadata/gc.c