[Mono-dev] mono crash on exits when using COM.
tom_hindle at sil.org
Fri Jan 22 20:26:45 EST 2010
I have added a check in mono_gc_run_finalize (void *obj, void *data)
+ if (mono_marshal_ccw_refcount(o) > 0)
domain = o->vtable->domain;
This seems to solve the problem. The ccw isn't freed, which means when
the rcw releases its reference to the ccw, so it no longer segv's.
Does this seem like an valid approach? I'm not sure If this means that
finalize_domain_objects needs to make multiple passes at freeing the
ccw's? I guess this change would also mean the badly written native COM
objects would prevent ccw from being freed. Is this a problem?
On Fri, 2010-01-22 at 16:16 -0700, tom hindle wrote:
> Hi all,
> I have been investigating some seemingly random crash on exit problems
> that our application has been having.
> I have managed mostly reliably to reproduce the issue by following this
> set of steps:
> 1. Create a managed object ManagedObj
> 2. Create a COM object COMObj for which its rcw is likely to be Garbage
> collected after ManagedObj and during mono shutdown.
> 3. Make COMObj contain a ref to ManagedObj's ccw
> 4. Set ManagedObj ref to null
> 5. Call GC.Collect() to encourage GC.
> If Garbage Collection of COMObj's rcw happens after the Garbage
> Collection of ManagedObj's ccw, then when COMObj calls Release on its
> ref to ManagedObj's ccw a segv is produced.
> Normally it seems that ref counts for the wrappers are respected,
> however this doesn't seem to be the case on program shutdown.
> Some pseudo code which reproduces the problem:
> public class TestComRelease
> static COMObj cObj;
> public void Test()
> ManagedObj mObj = new ManagedObj()
> cObj = new COMObj();
> mObj = null;
> I am attempting to find the cause of this in mono. Any pointers would be
> grateful received.
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list