[Gtk-sharp-list] Random NullReferenceExceptions in GLib

Mike Kestner mkestner@novell.com
Mon, 09 May 2005 16:02:34 -0500


On Fri, 2005-05-06 at 18:39 -0700, Todd Berman wrote:

> > Unhandled Exception: System.NullReferenceException: Object reference not
> > set to an instance of an object
> > in (unmanaged) 0x8ac9250
> > in <0x00004> (wrapper managed-to-native) GLib.Object:g_object_unref
> > (intptr)
> > in [0x00099] (at /home/brady/sources/gtk-sharp/glib/Object.cs:65)
> > GLib.Object:PerformQueuedUnrefs ()

> I am actually starting to see this too, not sure what is going on at
> all, and it is also exposing itself under win32, so it is not linux
> specific. I am wondering what has recently changed.

Looks like an attempt to unref an object that's already been finalized.
Generally, I start tracking these down by putting a C.WL in
PerformQueuedUnrefs to identify the type of object being released.  Put
the C.WL before the g_object_unref call too so you know the type of the
object being "disposed".

I'm considering putting a try/catch around that to throw a useful
exception to at least identify the type being disposed when all hell
breaks loose.

-- 
Mike Kestner <mkestner@novell.com>