When cleaning up the finalizers of a domain, do it in a way that reduces the chance...
commitb02f9ac6bb7e732b3e0795f8a91e600da159eecc
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 7 May 2012 14:31:22 +0000 (7 11:31 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 7 May 2012 16:52:43 +0000 (7 13:52 -0300)
treebd35d922deb2e1550f933e406497b250f0963916
parent528213d413c78d8b0e04042a30153b7ed85e00c8
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