Skip to content
This repository

Crash occurred on Mono #16

Closed
lextm opened this Issue May 26, 2012 · 13 comments

3 participants

Lex Li jumpinjackie Ryan Rastedt
Lex Li
Collaborator
lextm commented May 26, 2012

Steps to reproduce it

  1. Compile the source code on Linux using xbuild or MonoDevelop.
  2. Go to DockSample binary folder (DockSample/bin/Debug), and open a Terminal.
  3. Execute "mono DockSample.exe".
  4. Repeat step 3, and this time click View | Solution Explorer menu item to open Solution Explorer panel.

After step 3, when you see the DockSample window, please close it immediately (File | Close Without Saving Layout). Here you only see an exception at the Terminal,

lextm@linux-9xno:~/Projects/dockpanelsuite/DockSample/bin/Debug> mono DockSample.exe
X11 Error encountered: 
  Error: BadMatch (invalid parameter attributes)
  Request:     12 (0)
  Resource ID: 0x360001E
  Serial:      522
  Hwnd:        Hwnd, Mapped:True ClientWindow:0x360001F, WholeWindow:0x360001E, Zombie=False, Parent:[<null>]
  Control:     WeifenLuo.WinFormsUI.Docking.DockPanel, BorderStyle: None   at System.Environment.get_StackTrace()
   at System.Windows.Forms.XplatUIX11.HandleError(IntPtr display, XErrorEvent ByRef error_event)
   at System.Windows.Forms.XplatUIX11.XTranslateCoordinates(IntPtr , IntPtr , IntPtr , Int32 , Int32 , Int32 ByRef , Int32 ByRef , IntPtr ByRef )
   at System.Windows.Forms.XplatUIX11.ClientToScreen(IntPtr handle, Int32 ByRef x, Int32 ByRef y)
   at System.Windows.Forms.XplatUI.ClientToScreen(IntPtr handle, Int32 ByRef x, Int32 ByRef y)
   at System.Windows.Forms.Control.PointToScreen(Point p)
   at System.Windows.Forms.Control.RectangleToScreen(Rectangle r)
   at WeifenLuo.WinFormsUI.Docking.DockPanel.GetAutoHideWindowBounds(Rectangle rectAutoHideWindow)
   at WeifenLuo.WinFormsUI.Docking.DockPanel.OnLayout(System.Windows.Forms.LayoutEventArgs levent)
   at System.Windows.Forms.Control.PerformLayout(System.Windows.Forms.Control affectedControl, System.String affectedProperty)
   at System.Windows.Forms.ScrollableControl.OnVisibleChanged(System.EventArgs e)
   at WeifenLuo.WinFormsUI.Docking.DockPanel.OnVisibleChanged(System.EventArgs e)
   at System.Windows.Forms.Control.OnParentVisibleChanged(System.EventArgs e)
   at System.Windows.Forms.Control.OnVisibleChanged(System.EventArgs e)
   at System.Windows.Forms.ScrollableControl.OnVisibleChanged(System.EventArgs e)
   at System.Windows.Forms.Form.OnVisibleChanged(System.EventArgs e)
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at System.Windows.Forms.Application.RunLoop(Boolean Modal, System.Windows.Forms.ApplicationContext context)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext context)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)
   at DockSample.Program.Main()

This is a warning which is not critical at this moment.

However, after step 4, if close DockSample window (File | Close Without Saving Layout), you will see at Terminal tons of logs and finally the process terminates with a runtime error.

Workaround
A possible workaround is to close all DockContent manually in DockSample MainForm's Closing event before exiting.

This workaround has been tested in #SNMP MIB Browser and Compiler.

Root Cause
As this does not happen on Windows, I know it must be caused by the Mono patch #7/#8.

Will later investigate and resolve it.

Lex Li
Collaborator
lextm commented May 26, 2012

The beginning of the crash log is as below, which should recursive calls.

Stack overflow: IP: 0x41e07d24, fault addr: (nil)
Stacktrace:
at WeifenLuo.WinFormsUI.Docking.DockPanel.SuspendLayout (bool)
<...>
at (wrapper remoting-invoke-with-check) WeifenLuo.WinFormsUI.Docking.DockPanel.SuspendLayout (bool)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_Pane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_DockPanel (WeifenLuo.WinFormsUI.Docking.DockPanel)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Form_Disposed (object,System.EventArgs)
at System.ComponentModel.Component.Dispose (bool)
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at System.Windows.Forms.Form.Dispose (bool)
at DockSample.ToolWindow.Dispose (bool)
at DockSample.DummySolutionExplorer.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockPane.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.RemoveFromPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_PanelPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_Pane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_DockPanel (WeifenLuo.WinFormsUI.Docking.DockPanel)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Form_Disposed (object,System.EventArgs)
at System.ComponentModel.Component.Dispose (bool)
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at System.Windows.Forms.Form.Dispose (bool)
at DockSample.ToolWindow.Dispose (bool)
at DockSample.DummySolutionExplorer.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockPane.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.RemoveFromPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_PanelPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_Pane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_DockPanel (WeifenLuo.WinFormsUI.Docking.DockPanel)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Form_Disposed (object,System.EventArgs)
at System.ComponentModel.Component.Dispose (bool)
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at System.Windows.Forms.Form.Dispose (bool)
at DockSample.ToolWindow.Dispose (bool)
at DockSample.DummySolutionExplorer.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockPane.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.RemoveFromPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_PanelPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_Pane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_DockPanel (WeifenLuo.WinFormsUI.Docking.DockPanel)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Form_Disposed (object,System.EventArgs)
at System.ComponentModel.Component.Dispose (bool)
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at System.Windows.Forms.Form.Dispose (bool)
at DockSample.ToolWindow.Dispose (bool)
at DockSample.DummySolutionExplorer.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockPane.Dispose (bool)
at System.ComponentModel.Component.Dispose ()
at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.RemoveFromPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_PanelPane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_Pane (WeifenLuo.WinFormsUI.Docking.DockPane)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_DockPanel (WeifenLuo.WinFormsUI.Docking.DockPanel)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose (bool)
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Dispose ()
at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Form_Disposed (object,System.EventArgs)
at System.ComponentModel.Component.Dispose (bool)
at System.Windows.Forms.Control.Dispose (bool)
at System.Windows.Forms.ContainerControl.Dispose (bool)
at System.Windows.Forms.Form.Dispose (bool)

Lex Li
Collaborator
lextm commented May 26, 2012

To get the full log, make sure in step 4 you execute "mono DockSample.exe > crash.log 2>&1" at Terminal so that all log entries go to crash.log.

Lex Li
Collaborator
lextm commented June 08, 2012

By changing Win32Helper.IsRunningOnMono to always return true, I tried to reproduce the crash on Windows/.NET. However, I could not reproduce it. So now it seems to be a Mono issue (where Mono disposes objects differently).

Will review JArchitect's team's patch to see how they work around this difference.

Lex Li
Collaborator
lextm commented June 09, 2012

Tested with Mono 2.10.8 on Windows. The crash can be also reproduced.

Tested with Mono 2.11.1 alpha on Windows. The crash cannot be reproduced. It seems that the Mono issue has been fixed. However, another issue has been observed, which will be documented in another issue if Mono 2.11 finalizes.

jumpinjackie

Just to add a data point. I had a similar crash in DockPanel in my application when running in Mono 2.10 (happens on exit), which I was able to workaround with boolean guard in DockContentHandler.Dispose()

http://trac.osgeo.org/mapguide/changeset/6768/trunk/Tools/Maestro

Ryan Rastedt
Owner
roken commented July 12, 2012

This is curious, I would be interested in finding some documentation on this Mono bug...I wasn't able to locate anything after a quick search. It would seem that the call to DockPane.RemoveContent() believes the content doesn't exist in the Contents collection and returns without actually detaching the content.

As an unrelated side note, why are we locking in the DockContentHandler's Dispose(bool) method? Disposal should be happening on the UI thread; this lock seems superfluous.

Lex Li
Collaborator
lextm commented July 12, 2012

@jumpinjackie 's fix is interesting to me too. If it works then the disposal methods need to be carefully reviewed then. I did not yet test the current build on Mono 2.11 on openSUSE. Will perform more investigation on that and provide an update back here.

Lex Li
Collaborator
lextm commented July 14, 2012

Just tested on Mono 2.11.2/openSUSE 12.1. DockSample.exe crashed due to broken WinForms support. Will have to wait till another Mono release.

Next I am going to test @jumpinjackie 's patch and see if it works as desired. If yes, I will further investigate what are the other possible fixes.

Lex Li
Collaborator
lextm commented July 14, 2012

Modified a build of DPS to generate log entries in related Dispose method so as to track the disposing order. The result on Windows/.NET is as below,

Enter AutoHideWindowControl 7
Leave 7
Enter DockPanel 5
    Enter MdiClientController 9
    Leave 9
    Enter DockPaneCollection 6
        Enter DockPane 11
            Enter VS2005DockPaneCaption 12
            Leave 12
            Enter VS2005DockPaneStrip 13
            Leave 13
            Enter DockContentHandler 10
                Enter DockPane 11
                Leave 11
            Leave 10
        Leave 11
    Leave 6
    Enter DockContentHandler 8
    Leave 8
Leave 5

The DockPane's Dispose method was called twice. Since the second call does nothing, there is no infinite loop. Will run this build on Mono and see what is the result there.

Lex Li
Collaborator
lextm commented July 14, 2012

On Mono the result is quite different,

Enter AutoHideWindowControl 7
Leave 7
Enter DockPanel 5
    Enter MdiClientController 9
    Leave 9
    Enter DockPaneCollection 6
        Enter DockPane 11
            Enter VS2005DockPaneCaption 12
            Leave 12
            Enter VS2005DockPaneStrip 13
            Leave 13
            Enter DockContentHandler 10
                Enter DockPane 11
                    Enter VS2005DockPaneCaption 12
                    Leave 12
                    Enter VS2005DockPaneStrip 13
                    Leave 13
                    Enter DockContentHandler 10
                        Enter DockPane 11
                            Enter VS2005DockPaneCaption 12

So the second call to DockPane.Disposing(true) leads to an infinite loop of calls.

Lex Li
Collaborator
lextm commented July 14, 2012

As above shows, to avoid the issue on Mono, we might patch DockPane.Dispose to return immediately on the second call, which is better than @jumpinjackie 's patch. I have tested it locally on Mono 2.10.9/openSUSE 12.1. Will revise the patch later and commit.

Lex Li lextm closed this July 14, 2012
Lex Li
Collaborator
lextm commented July 18, 2012
Ryan Rastedt
Owner
roken commented July 18, 2012

I have logged a bug with mono: https://bugzilla.xamarin.com/show_bug.cgi?id=6176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.