Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Loading fsharp projects hang if vi mode are enabled #244

Closed
kjnilsson opened this issue Nov 12, 2013 · 17 comments
Closed

Loading fsharp projects hang if vi mode are enabled #244

kjnilsson opened this issue Nov 12, 2013 · 17 comments

Comments

@kjnilsson
Copy link
Contributor

  1. Enable vi mode in XS preferences
  2. Load or create a new fsharp project
  3. XS should hang using 100% cpu

XS versions tested: 4.2 (beta channel) (4.1.13 alpha channel)
fsharp bindings built from source (commit: 8d640f2) + latest available in add-in manager (3.2.20 or 3.2.21).

The problem appears to occur whilst loading a file (rather than project loading). If you load an fsharp project with the vi mode disabled you can later enable and use it. The issue only occurs during or after project load.

I am not sure if the issue is in the fsharp bindings or the vi mode. The code for the vi mode is not the most elegant I have ever seen and there are a few bugs there that I would like to fix anyway so unless someone has a good idea of why this has started happening I am happy to investigate this issue further. (I guess the number of vi users that use fsharp in XS at this time isn't massive large :))

@kjnilsson
Copy link
Contributor Author

Perhaps there is some relation to issue 227. Don's comment about something never terminating could be interesting to look into. #227

@7sharp9
Copy link
Member

7sharp9 commented Nov 12, 2013

Feel free to look into it, can't say I've ever used the vi mode ...

@7sharp9
Copy link
Member

7sharp9 commented Nov 12, 2013

I just turned on the vi mode and everything loaded as normal.

@kjnilsson
Copy link
Contributor Author

Odd. I can reproduce reliably here. I wonder if there is anything
environment specific that has got changed on my machine then. I'll try it
on my work windows box as well.

On Tuesday, 12 November 2013, Dave Thomas wrote:

I just turned on the vi mode and everything loaded as normal.


Reply to this email directly or view it on GitHubhttps://github.com//issues/244#issuecomment-28275906
.

Karl Nilsson
twitter: @kjnilsson
blog: coderkarl.wordpress.com

@ronnieholm
Copy link

My XS 4.0.13 on Windows hangs as well.

@kjnilsson
Copy link
Contributor Author

With the latest fsharp bindings?

On Tuesday, 12 November 2013, Ronnie Holm wrote:

My XS 4.0.13 on Windows hangs as well.


Reply to this email directly or view it on GitHubhttps://github.com//issues/244#issuecomment-28276676
.

Karl Nilsson
twitter: @kjnilsson
blog: coderkarl.wordpress.com

@ronnieholm
Copy link

Yes, the most recent fsharp bindings.

I created a dump file from the busy XS and opened it with Windbg. See stack trace of busy thread at the bottom. It looks like calling Mono.TextEditor.Vi.ViStatusArea.AllocateArea causes Gtk to loop.

0:000> .sympath SRV*e:\localsymbols*http://msdl.microsoft.com/download/symbols
Symbol search path is: SRV*e:\localsymbols*http://msdl.microsoft.com/download/symbols
Expanded Symbol search path is: srv*e:\localsymbols*http://msdl.microsoft.com/download/symbols
0:000> .loadby sos clr
0:000> !runaway
 User Mode Time
  Thread       Time
   0:1d1c      0 days 0:07:51.029
   9:1e5c      0 days 0:00:00.218
   4:1cc8      0 days 0:00:00.218
  11:19f4      0 days 0:00:00.046
  10:c54       0 days 0:00:00.015
   2:1ae8      0 days 0:00:00.015
  21:fec       0 days 0:00:00.000
  20:1590      0 days 0:00:00.000
  19:1b5c      0 days 0:00:00.000
  18:a24       0 days 0:00:00.000
  17:1a70      0 days 0:00:00.000
  16:19dc      0 days 0:00:00.000
  15:c38       0 days 0:00:00.000
  14:1d08      0 days 0:00:00.000
  13:1fbc      0 days 0:00:00.000
  12:15fc      0 days 0:00:00.000
   8:1a28      0 days 0:00:00.000
   7:1c9c      0 days 0:00:00.000
   6:1e88      0 days 0:00:00.000
   5:1974      0 days 0:00:00.000
   3:1fd0      0 days 0:00:00.000
   1:1e98      0 days 0:00:00.000
0:000> ~0s
eax=00000000 ebx=00177d64 ecx=0000007f edx=0000016c esi=61a79326 edi=00000000
eip=054a6bfb esp=00177b6c ebp=00177ba4 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00200246
libglib_2_0_0!g_dngettext+0x1f9:
054a6bfb 0f8567ffffff    jne     libglib_2_0_0!g_dngettext+0x166 (054a6b68) [br=0]
0:000> !CLRStack
OS Thread Id: 0x1d1c (0)
Child SP       IP Call Site
0017832c 054a6bfb [InlinedCallFrame: 0017832c] 
001782fc 0c30fc9a DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, Double, Double, Double, Double, Double)
0017832c 0d7693e8 [InlinedCallFrame: 0017832c] Gtk.Adjustment.gtksharp_gtk_adjustment_set_bounds(IntPtr, Double, Double, Double, Double, Double)
001783c0 0d7693e8 Gtk.Adjustment.SetBounds(Double, Double, Double, Double, Double)
001783f0 0d769068 Mono.TextEditor.TextArea.SetHAdjustment()
00178544 0d76871b Mono.TextEditor.TextArea.SetAdjustments(Gdk.Rectangle)
00178628 101c47e8 Mono.TextEditor.TextArea.OnSizeAllocated(Gdk.Rectangle)
00178664 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
00178a0c 002fa97c [InlinedCallFrame: 00178a0c] 
00178a00 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
00178a0c 0afe7755 [InlinedCallFrame: 00178a0c] Gtk.Widget.gtk_widget_size_allocate(IntPtr, IntPtr)
00178a58 0afe7755 Gtk.Widget.SizeAllocate(Gdk.Rectangle)
00178a7c 101c46f5 Mono.TextEditor.Vi.ViStatusArea.AllocateArea(Mono.TextEditor.TextArea, Gdk.Rectangle)
00178ae4 101c45d1 Mono.TextEditor.Vi.ViEditMode.AllocateTextArea(Mono.TextEditor.TextEditor, Mono.TextEditor.TextArea, Gdk.Rectangle)
00178b0c 101c4541 Mono.TextEditor.TextEditor.OnSizeAllocated(Gdk.Rectangle)
00178b2c 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
00178f44 002fa97c [InlinedCallFrame: 00178f44] 
00178f38 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
00178f44 0857c435 [InlinedCallFrame: 00178f44] Gtk.Widget.gtksharp_widget_base_size_allocate(IntPtr, IntPtr)
00178f90 0857c435 Gtk.Widget.OnSizeAllocated(Gdk.Rectangle)
00178fb4 0c30cb6c MonoDevelop.Components.CompactScrolledWindow.OnSizeAllocated(Gdk.Rectangle)
001790b4 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017b8ac 002fa97c [InlinedCallFrame: 0017b8ac] 
0017b8a0 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
0017b8ac 0afe7755 [InlinedCallFrame: 0017b8ac] Gtk.Widget.gtk_widget_size_allocate(IntPtr, IntPtr)
0017b8f8 0afe7755 Gtk.Widget.SizeAllocate(Gdk.Rectangle)
0017b91c 0c30c768 MonoDevelop.Components.Docking.DockGroupItem.SizeAllocate(Gdk.Rectangle)
0017b99c 0bde5ad2 MonoDevelop.Components.Docking.DockGroup.SizeAllocate(Gdk.Rectangle)
0017bc78 0bde5a28 MonoDevelop.Components.Docking.DockGroup.SizeAllocate(Gdk.Rectangle)
0017bf54 0bde4e5e MonoDevelop.Components.Docking.DockLayout.SizeAllocate(Gdk.Rectangle)
0017bf70 0afe76a9 MonoDevelop.Components.Docking.DockContainer.OnSizeAllocated(Gdk.Rectangle)
0017bfb4 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017cb2c 002fa97c [InlinedCallFrame: 0017cb2c] 
0017cb20 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
0017cb2c 0857c435 [InlinedCallFrame: 0017cb2c] Gtk.Widget.gtksharp_widget_base_size_allocate(IntPtr, IntPtr)
0017cb78 0857c435 Gtk.Widget.OnSizeAllocated(Gdk.Rectangle)
0017cb9c 0afe735f MonoDevelop.Components.Docking.DockFrame.OnSizeAllocated(Gdk.Rectangle)
0017cc60 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017e368 002fa97c [InlinedCallFrame: 0017e368] 
0017e35c 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
0017e368 0857c435 [InlinedCallFrame: 0017e368] Gtk.Widget.gtksharp_widget_base_size_allocate(IntPtr, IntPtr)
0017e3b4 0857c435 Gtk.Widget.OnSizeAllocated(Gdk.Rectangle)
0017e3d8 0857c2c1 MonoDevelop.Ide.Gui.WorkbenchWindow.OnSizeAllocated(Gdk.Rectangle)
0017e468 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017eed8 002fa97c [InlinedCallFrame: 0017eed8] 
0017eed4 0702094f DomainBoundILStubClass.IL_STUB_PInvoke()
0017eed8 0bde26e5 [InlinedCallFrame: 0017eed8] Gtk.Application.gtk_main()
0017ef14 0bde26e5 Gtk.Application.Run()
0017ef18 0bde26c0 MonoDevelop.Ide.IdeApp.Run()
0017ef20 005177b8 MonoDevelop.Ide.IdeStartup.Run(MonoDevelop.Ide.MonoDevelopOptions)
0017f298 0051036b MonoDevelop.Ide.IdeStartup.Main(System.String[])
0017f34c 0051007b *** WARNING: Unable to verify checksum for XamarinStudio.exe
*** ERROR: Module load completed but symbols could not be loaded for XamarinStudio.exe
Xamarin.Startup.MainClass.Main(System.String[])
0017f4dc 6c7c2652 [GCFrame: 0017f4dc] 

@ronnieholm
Copy link

I'm no expert at reading Windbg output, but the above stacktrace is for managed code only. Gtk is unmanaged code as well and looking at the top of the unmanaged stack, I notice calls to mutex_lock. Perhaps Gtk is busy waiting because of a deadlock.

0:000> !dumpstack
The version of SOS does not match the version of CLR you are debugging.  Please
load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.0.30319.17929
SOS Version: 4.0.30319.18408
OS Thread Id: 0x1d1c (0)
Current frame: libglib_2_0_0!g_dngettext+0x1f9
ChildEBP RetAddr  Caller, Callee
00177ba4 054a78c7 libglib_2_0_0!g_hash_table_lookup+0x48, calling libglib_2_0_0!g_dngettext+0xf8
00177bb4 63a64a62 *** ERROR: Symbol file could not be found.  Defaulted to export symbols for libgobject-2.0-0.dll - 
libgobject_2_0_0!g_type_next_base+0x256, calling libgobject_2_0_0!g_type_next_base+0x8e
00177bd4 63a53188 libgobject_2_0_0!g_param_spec_pool_remove+0xe8, calling libglib_2_0_0!g_hash_table_lookup
00177be4 63a64ab4 libgobject_2_0_0!g_type_is_a+0x50, calling libgobject_2_0_0!g_type_next_base+0x228
00177bf0 054fcca9 libglib_2_0_0!g_mutex_lock+0x14
00177c04 054fcca9 libglib_2_0_0!g_mutex_lock+0x14
00177c14 618c73ff *** ERROR: Symbol file could not be found.  Defaulted to export symbols for libgtk-win32-2.0-0.dll - 
libgtk_win32_2_0_0!gtk_style_set_background+0x20f, calling msvcrt!bsearch

@kjnilsson
Copy link
Contributor Author

Great - I wouldn't even know how to do that on mono. Need to figure that
out one day. :)

from the monodevelop source it looks like the AllocateArea method could
cause issues if the textArea.SizeAllocate doesn't succeed but I don't fully
understand how it all works.

          public void AllocateArea (TextArea textArea,

Gdk.Rectangle allocation)
{
if (!Visible)
Show ();
allocation.Height -= (int)textArea.LineHeight;
if (textArea.Allocation != allocation)
textArea.SizeAllocate (allocation);
SetSizeRequest (allocation.Width,
(int)editor.LineHeight);
var pos =
((TextEditor.EditorContainerChild)editor [this]);
if (pos.X != 0 || pos.Y != allocation.Height)
editor.MoveTopLevelWidget (this, 0,
allocation.Height);
}

On 12 November 2013 09:26, Ronnie Holm notifications@github.com wrote:

Yes, the most recent fsharp bindings.

I created a dump file from the busy XS and opened it with Windbg. See
stack trace of busy thread at the bottom. It looks like calling
Mono.TextEditor.Vi.ViStatusArea.AllocateArea causes Gtk to loop.

0:000> .sympath SRV_e:\localsymbols_http://msdl.microsoft.com/download/symbols
Symbol search path is: SRV_e:\localsymbols_http://msdl.microsoft.com/download/symbols
Expanded Symbol search path is: srv_e:\localsymbols_http://msdl.microsoft.com/download/symbols
0:000> .loadby sos clr
0:000> !runaway
User Mode Time
Thread Time
0:1d1c 0 days 0:07:51.029
9:1e5c 0 days 0:00:00.218
4:1cc8 0 days 0:00:00.218
11:19f4 0 days 0:00:00.046
10:c54 0 days 0:00:00.015
2:1ae8 0 days 0:00:00.015
21:fec 0 days 0:00:00.000
20:1590 0 days 0:00:00.000
19:1b5c 0 days 0:00:00.000
18:a24 0 days 0:00:00.000
17:1a70 0 days 0:00:00.000
16:19dc 0 days 0:00:00.000
15:c38 0 days 0:00:00.000
14:1d08 0 days 0:00:00.000
13:1fbc 0 days 0:00:00.000
12:15fc 0 days 0:00:00.000
8:1a28 0 days 0:00:00.000
7:1c9c 0 days 0:00:00.000
6:1e88 0 days 0:00:00.000
5:1974 0 days 0:00:00.000
3:1fd0 0 days 0:00:00.000
1:1e98 0 days 0:00:00.000
0:000> ~0s
eax=00000000 ebx=00177d64 ecx=0000007f edx=0000016c esi=61a79326 edi=00000000
eip=054a6bfb esp=00177b6c ebp=00177ba4 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00200246
libglib_2_0_0!g_dngettext+0x1f9:
054a6bfb 0f8567ffffff jne libglib_2_0_0!g_dngettext+0x166 (054a6b68) [br=0]
0:000> !CLRStack
OS Thread Id: 0x1d1c (0)
Child SP IP Call Site
0017832c 054a6bfb [InlinedCallFrame: 0017832c]
001782fc 0c30fc9a DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, Double, Double, Double, Double, Double)
0017832c 0d7693e8 [InlinedCallFrame: 0017832c] Gtk.Adjustment.gtksharp_gtk_adjustment_set_bounds(IntPtr, Double, Double, Double, Double, Double)
001783c0 0d7693e8 Gtk.Adjustment.SetBounds(Double, Double, Double, Double, Double)
001783f0 0d769068 Mono.TextEditor.TextArea.SetHAdjustment()
00178544 0d76871b Mono.TextEditor.TextArea.SetAdjustments(Gdk.Rectangle)
00178628 101c47e8 Mono.TextEditor.TextArea.OnSizeAllocated(Gdk.Rectangle)
00178664 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
00178a0c 002fa97c [InlinedCallFrame: 00178a0c]
00178a00 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
00178a0c 0afe7755 [InlinedCallFrame: 00178a0c] Gtk.Widget.gtk_widget_size_allocate(IntPtr, IntPtr)
00178a58 0afe7755 Gtk.Widget.SizeAllocate(Gdk.Rectangle)
00178a7c 101c46f5 Mono.TextEditor.Vi.ViStatusArea.AllocateArea(Mono.TextEditor.TextArea, Gdk.Rectangle)
00178ae4 101c45d1 Mono.TextEditor.Vi.ViEditMode.AllocateTextArea(Mono.TextEditor.TextEditor, Mono.TextEditor.TextArea, Gdk.Rectangle)
00178b0c 101c4541 Mono.TextEditor.TextEditor.OnSizeAllocated(Gdk.Rectangle)
00178b2c 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
00178f44 002fa97c [InlinedCallFrame: 00178f44]
00178f38 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
00178f44 0857c435 [InlinedCallFrame: 00178f44] Gtk.Widget.gtksharp_widget_base_size_allocate(IntPtr, IntPtr)
00178f90 0857c435 Gtk.Widget.OnSizeAllocated(Gdk.Rectangle)
00178fb4 0c30cb6c MonoDevelop.Components.CompactScrolledWindow.OnSizeAllocated(Gdk.Rectangle)
001790b4 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017b8ac 002fa97c [InlinedCallFrame: 0017b8ac]
0017b8a0 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
0017b8ac 0afe7755 [InlinedCallFrame: 0017b8ac] Gtk.Widget.gtk_widget_size_allocate(IntPtr, IntPtr)
0017b8f8 0afe7755 Gtk.Widget.SizeAllocate(Gdk.Rectangle)
0017b91c 0c30c768 MonoDevelop.Components.Docking.DockGroupItem.SizeAllocate(Gdk.Rectangle)
0017b99c 0bde5ad2 MonoDevelop.Components.Docking.DockGroup.SizeAllocate(Gdk.Rectangle)
0017bc78 0bde5a28 MonoDevelop.Components.Docking.DockGroup.SizeAllocate(Gdk.Rectangle)
0017bf54 0bde4e5e MonoDevelop.Components.Docking.DockLayout.SizeAllocate(Gdk.Rectangle)
0017bf70 0afe76a9 MonoDevelop.Components.Docking.DockContainer.OnSizeAllocated(Gdk.Rectangle)
0017bfb4 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017cb2c 002fa97c [InlinedCallFrame: 0017cb2c]
0017cb20 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
0017cb2c 0857c435 [InlinedCallFrame: 0017cb2c] Gtk.Widget.gtksharp_widget_base_size_allocate(IntPtr, IntPtr)
0017cb78 0857c435 Gtk.Widget.OnSizeAllocated(Gdk.Rectangle)
0017cb9c 0afe735f MonoDevelop.Components.Docking.DockFrame.OnSizeAllocated(Gdk.Rectangle)
0017cc60 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017e368 002fa97c [InlinedCallFrame: 0017e368]
0017e35c 080bebeb DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, IntPtr)
0017e368 0857c435 [InlinedCallFrame: 0017e368] Gtk.Widget.gtksharp_widget_base_size_allocate(IntPtr, IntPtr)
0017e3b4 0857c435 Gtk.Widget.OnSizeAllocated(Gdk.Rectangle)
0017e3d8 0857c2c1 MonoDevelop.Ide.Gui.WorkbenchWindow.OnSizeAllocated(Gdk.Rectangle)
0017e468 0857bfc4 Gtk.Widget.sizeallocated_cb(IntPtr, IntPtr)
0017eed8 002fa97c [InlinedCallFrame: 0017eed8]
0017eed4 0702094f DomainBoundILStubClass.IL_STUB_PInvoke()
0017eed8 0bde26e5 [InlinedCallFrame: 0017eed8] Gtk.Application.gtk_main()
0017ef14 0bde26e5 Gtk.Application.Run()
0017ef18 0bde26c0 MonoDevelop.Ide.IdeApp.Run()
0017ef20 005177b8 MonoDevelop.Ide.IdeStartup.Run(MonoDevelop.Ide.MonoDevelopOptions)
0017f298 0051036b MonoDevelop.Ide.IdeStartup.Main(System.String[])
0017f34c 0051007b *** WARNING: Unable to verify checksum for XamarinStudio.exe
*** ERROR: Module load completed but symbols could not be loaded for XamarinStudio.exe
Xamarin.Startup.MainClass.Main(System.String[])
0017f4dc 6c7c2652 [GCFrame: 0017f4dc]


Reply to this email directly or view it on GitHubhttps://github.com//issues/244#issuecomment-28278978
.

Karl Nilsson
twitter: @kjnilsson
blog: coderkarl.wordpress.com

@7sharp9
Copy link
Member

7sharp9 commented Nov 12, 2013

Well, it doest look like an issue in the F# binding, you should just raise this as an issue with MonoDevelop via bugzilla

@kjnilsson
Copy link
Contributor Author

Dave - it doesn't happen for csharp projects so I am not sure it is a
'pure' mono develop bug. Does the fsharp bindings do anything related to
text area allocation?

On 12 November 2013 09:51, Dave Thomas notifications@github.com wrote:

Well, it doest look like an issue in the F# binding, you should just raise
this as an issue with MonoDevelop via bugzilla


Reply to this email directly or view it on GitHubhttps://github.com//issues/244#issuecomment-28280532
.

Karl Nilsson
twitter: @kjnilsson
blog: coderkarl.wordpress.com

@ronnieholm
Copy link

There're no F# binding frames visible in the stacktrace, so it doesn't look like an F# binding issue.

@7sharp9
Copy link
Member

7sharp9 commented Nov 12, 2013

@kjnilsson Theres only a tiny bit of UI in the F# binding, and thats in the C# project here

@7sharp9
Copy link
Member

7sharp9 commented Nov 12, 2013

The BuildOrderWidget needs to be removed too, thats been obsolete for a while now.

@knocte
Copy link
Contributor

knocte commented Nov 12, 2013

This may be because of the F# binding accessing the UI in the wrong thread. To discover this kind of issues, I recommend using the gui-thread-check (only works with Mono, not .NET, so setting it in Linux is easier I guess): https://github.com/slluis/gui-thread-check/

@kjnilsson
Copy link
Contributor Author

After doing some further testing I can confirm this is not isolated to the fsharp addin. It happens with other addidns including c#. I will create a monodevelop bug report and close this one.

@kjnilsson
Copy link
Contributor Author

Discussing it with the MD guys here: https://bugzilla.xamarin.com/show_bug.cgi?id=15596

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants