[Mono-osx] Exception disposing of object

Michael Hutchinson m.j.hutchinson at gmail.com
Wed Jun 13 18:38:21 UTC 2012


Could you please file a bug with the test project attached?

On 13 June 2012 14:31, Jon Lipsky <jon.lipsky at elevenworks.com> wrote:
> Hi All,
>
> I'm getting random crashes in my MonoMac application in the
> "NSObject.MonoMac_Disposer.Drain" method:
>
>  at (wrapper managed-to-native)
> MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper (intptr,intptr) <IL
> 0x00024, 0xffffffff>
>   at MonoMac.Foundation.NSObject/MonoMac_Disposer.Drain
> (MonoMac.Foundation.NSObject) [0x0003b] in
> /Development/github/monomac/src/Foundation/NSObject.cs
>   at (wrapper dynamic-method)
> object.[MonoMac.Foundation.NSObject+MonoMac_Disposer.Void
> Drain(MonoMac.Foundation.NSObject)]
> (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject)
> <IL 0x00011, 0x0004b>
>   at (wrapper native-to-managed)
> object.[MonoMac.Foundation.NSObject+MonoMac_Disposer.Void
> Drain(MonoMac.Foundation.NSObject)]
> (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject)
> <IL 0x000b6, 0xffffffff>
>   at (wrapper managed-to-native)
> MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <IL 0x0009d,
> 0xffffffff>
>
>
> By building my own version of MonoMac, I've been able to figure out that
> this crash always occurs when it's trying to dispose of the "super_handle"
> of my NSWindow subclass.
>
>
> Has anyone seen this?  Am I doing something wrong, or could there possibly
> be an issue with MonoMac here?
>
>
> It's quite easy to reproduce this issue:
>
> 1) Create a new MonoMac document based project.
>
> 2) Create a subclass of NSWindow:
>
> using System;
> using System.Collections.Generic;
> using System.Drawing;
> using MonoMac.AppKit;
>
> namespace DisposalProblem
> {
> public class TestWindow : NSWindow
> {
> public TestWindow () : base(new
> RectangleF(100,100,500,500),NSWindowStyle.Resizable |
> NSWindowStyle.Closable, NSBackingStore.Buffered, false)
> {
> }
>
>
> public TestWindow (IntPtr aIntPtr) : base(aIntPtr)
> {
> }
> }
> }
>
>
> 3) Use interface builder to have one of the pull down menus send the message
> "showTestWindow:".
>
> 4) Add the following to your AppDelegate class:
>
> private TestWindow testWindow;
>
>
> [Export("showTestWindow:")]
> public void ShowTestWindow()
> {
> if (testWindow == null)
> {
> testWindow = new TestWindow();
> testWindow.WillClose += HandleWillClose;
> }
>
>
> testWindow.MakeKeyAndOrderFront(this);
> testWindow.Center();
> }
>
> void HandleWillClose (object sender, EventArgs e)
> {
> testWindow.WillClose -= HandleWillClose;
> testWindow = null;
> }
>
> 5) Run the application, and open and close the window using the "wired up"
> menu item.  Should take less than 20 seconds to make it crash.
>
>
> Any help anyone could provide would be appreciated.
>
> Thanks,
> Jon...
>
>
>
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>



-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Mono-osx mailing list