[Gtk-sharp-list] Crashes at random spots
Eric Albright
albright at wesayhome.org
Wed Sep 6 20:16:02 EDT 2006
I received one reply off list that solved my problem. So I'll summarize
it here.
It turns out that even when you label your main function with
[STAThread] on a dual-core machine, we get problems with weird crashes.
The solution is to use the following thread idiom: ||
Glib.Thread.Init();
Gdk.Threads.Init();
Application.Init();
Gdk.Threads.Enter();
try
{
Application.Run();
}
finally
{
Gdk.Threads.Leave();
}
<http://www.go-mono.com/docs/index.aspx?link=T%3AGdk.Threads>Mono's
discussion of threads
(http://www.go-mono.com/docs/index.aspx?link=T:Gdk.Threads) applies,
although it indicates that it is only applicable to multi-threaded
applications, .NET applications are effectively multi-threaded even when
it seems that you are writing a single threaded application.
Eric
Eric Albright wrote:
> Hi,
>
> We have been experiencing crazy random crashes that give us one of the
> messages: "Attempted to read or write protected memory. This is often an
> indication that other memory is corrupt." or "Object reference not set
> to an instance of an object.". The stack indicates that it is trying to
> destroy GTK objects. Our program dynamically generates a form based on
> the data underneath and it consistently happens while iterating through
> records. I tried to reproduce this on my machine at home and was unable
> to which then led me to believe that perhaps there was a threading
> problem since our machines at work are dual core machines.
>
> I thought perhaps it had to do with interaction with the garbage
> collector on a different thread and so I set gcConcurrent=false in the
> app.config, but this hasn't solved the problem.
>
> Anyone have any pointers or ideas?
>
> Thanks,
>
> Eric
> wesay.org
>
> "Object reference not set to an instance of an object."
> at GLib.Signal.OnNativeDestroy(IntPtr data, IntPtr obj)
> at GLib.Signal.g_object_set_data(IntPtr instance, IntPtr key, IntPtr
> data)
> at GLib.Signal.DisconnectObject()
> at GLib.Signal.RemoveDelegate(Delegate d)
> at Gtk.Object.Dispose()
> at Gtk.Alignment.Finalize()
>
> "Attempted to read or write protected memory. This is often an
> indication that other memory is corrupt."
> at Gtk.Object.gtk_object_destroy(IntPtr raw)
> at Gtk.Widget.Destroy()
> at WeSay.LexicalTools.EntryViewTool.RefreshDetailArea(Box parent) in
> C:\WeSay\src\LexicalTools\EntryViewTool.cs:line 113
> at WeSay.LexicalTools.EntryViewTool.OnPositionChanged(Object sender,
> EventArgs e) in C:\WeSay\src\LexicalTools\EntryViewTool.cs:line 133
> at System.Windows.Forms.BindingSource.OnPositionChanged(EventArgs e)
> at
> System.Windows.Forms.BindingSource.CurrencyManager_PositionChanged(Object
> sender, EventArgs e)
> at System.Windows.Forms.CurrencyManager.OnPositionChanged(EventArgs e)
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
More information about the Gtk-sharp-list
mailing list