Bug 5994 - Code completion freezes when writing generics in MonoTouch projects
Summary: Code completion freezes when writing generics in MonoTouch projects
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 3.0.x
Hardware: Macintosh Mac OS
: Low normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2012-07-06 00:28 UTC by tome
Modified: 2012-07-09 08:50 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
A MonoTouch Library project to reproduce the accident (1.42 KB, application/octet-stream)
2012-07-06 11:37 UTC, tome
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description tome 2012-07-06 00:28:46 UTC
Description of Problem:
Code completion freezes when writing generics parameters like "<[in] T>" in C#,
though this is NOT correct code.


Steps to reproduce the problem:
1.  Create a C# project for MonoTouch (any type, e.g. Library)
2.  Open C# source code
3.  Write as following;
delegate void MyAction<[in] T> (T val);
or
class C1<[in] T>

that reproduces around the "<[i"


Additional Information:
(As far as) I confirmed that this happens within MonoTouch projects only.
And also confirmed that does not happens with the code completion disabled.
Comment 1 Mike Krüger 2012-07-06 02:23:29 UTC
Can't repro with mt projects in master.

Can you provide a console output for monodevelop using "kill -QUIT" against the MD process ?
(that causes monodevelop to write stacktraces of all threads to the MD log)
Comment 2 tome 2012-07-06 07:46:27 UTC
Thanks, Mike then I tried and got;

/Applications/MonoDevelop.app/Contents/MacOS/monodevelop --no-redirect
Full thread dump:

"Threadpool worker" tid=0x0xb0733000 this=0x0x6de61f8 thread handle 0x41f state : interrupted state owns ()

"Syntax highlighting" tid=0x0xb0a7f000 this=0x0x6de67e0 thread handle 0x45a state : interrupted state owns ()
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitOne () <0x0005f>
  at Mono.TextEditor.Highlighting.SyntaxModeService.ProcessQueue () <0x000ce>
  at System.Threading.Thread.StartInternal () <0x00059>
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

"<unnamed thread>" tid=0x0xb060f000 this=0x0x767ae70 thread handle 0x421 state : interrupted state owns ()
  at (wrapper managed-to-native) System.Threading.Thread.Sleep_internal (int) <0xffffffff>
  at System.Threading.Thread.Sleep (int) <0x00017>
  at System.IO.KeventWatcher.Monitor () <0x0023b>
  at System.Threading.Thread.StartInternal () <0x00059>
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

"Threapool monitor" tid=0x0xb0631000 this=0x0x6de62a0 thread handle 0x41e state : interrupted state owns ()

"Threadpool worker" tid=0x0xb08fb000 this=0x0xec26f18 thread handle 0x428 state : interrupted state owns ()
  at System.IO.MemoryStream.Read (byte[],int,int) <0x00006>
  at System.IO.StreamReader.ReadBuffer () <0x0003a>
  at System.IO.StreamReader.Read (char[],int,int) <0x0006b>
  at Mono.CSharp.SeekableStreamReader.ReadBuffer () <0x00083>
  at Mono.CSharp.SeekableStreamReader.Read () <0x0001f>
  at Mono.CSharp.Tokenizer.get_char () <0x00037>
  at Mono.CSharp.Tokenizer.xtoken () <0x01337>
  at Mono.CSharp.Tokenizer.token () <0x00013>
  at Mono.CSharp.Tokenizer.parse_less_than () <0x00033>
  at Mono.CSharp.Tokenizer.TokenizeLessThan () <0x0009f>
  at Mono.CSharp.Tokenizer.xtoken () <0x004c3>
  at Mono.CSharp.Tokenizer.token () <0x00013>
  at Mono.CSharp.CSharpParser.yyparse (Mono.CSharp.yyParser.yyInput) <0x001fc>
  at Mono.CSharp.CSharpParser.parse () <0x0007f>
  at Mono.CSharp.Driver.Parse (Mono.CSharp.SeekableStreamReader,Mono.CSharp.SourceFile,Mono.CSharp.ModuleContainer,int) <0x0010f>
  at ICSharpCode.NRefactory.CSharp.CSharpParser.Parse (System.IO.Stream,string,int) <0x001b7>
  at ICSharpCode.NRefactory.CSharp.CSharpParser.Parse (System.IO.TextReader,string,int) <0x000fb>
  at MonoDevelop.CSharp.Parser.TypeSystemParser.Parse (bool,string,System.IO.TextReader,MonoDevelop.Projects.Project) <0x002a7>
  at MonoDevelop.Ide.TypeSystem.TypeSystemService.ParseFile (MonoDevelop.Projects.Project,string,string,System.IO.TextReader) <0x000d9>
  at MonoDevelop.Ide.TypeSystem.TypeSystemService.ParseFile (MonoDevelop.Projects.Project,string,string,string) <0x0004b>
  at MonoDevelop.Ide.Gui.Document/<StartReparseThread>c__AnonStoreyA6/<StartReparseThread>c__AnonStoreyA7.<>m__158 (object) <0x000cb>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>

"<threadpool thread>" tid=0x0xb0755000 this=0x0x767af18 thread handle 0x424 state : interrupted state owns ()

"Background parser" tid=0x0xb050d000 this=0x0x6de6b28 thread handle 0x41a state : interrupted state owns ()
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitOne (int,bool) <0x0007f>
  at MonoDevelop.Ide.TypeSystem.TypeSystemService.WaitForParseJob (int) <0x0001b>
  at MonoDevelop.Ide.TypeSystem.TypeSystemService.ParserUpdateThread () <0x0002f>
  at System.Threading.Thread.StartInternal () <0x00059>
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

"Autosave" tid=0x0xb0b81000 this=0x0x68c9b28 thread handle 0x45f state : interrupted state owns ()
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitOne () <0x0005f>
  at MonoDevelop.SourceEditor.AutoSave.AutoSaveThread () <0x0001e>
  at System.Threading.Thread.StartInternal () <0x00059>
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

"IO Threadpool worker" tid=0x0xb0777000 this=0x0x767adc8 thread handle 0x425 state : interrupted state owns ()

"Background dispatcher" tid=0x0xb040b000 this=0x0xc4b28 thread handle 0x40b state : interrupted state owns ()
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitOne () <0x0005f>
  at MonoDevelop.Ide.DispatchService.backgroundDispatcher () <0x000c1>
  at System.Threading.Thread.StartInternal () <0x00059>
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

"GUI Thread" tid=0x0xac7f92c0 this=0x0xc4f18 thread handle 0x403 state : waiting on 0x4dc : Sem  owns ()
  at (wrapper managed-to-native) System.Threading.Monitor.try_enter_with_atomic_var (object,int,bool&) <0xffffffff>
  at System.Threading.Monitor.TryEnter (object,int,bool&) <0x0003b>
  at System.Threading.Monitor.Enter (object,bool&) <0x00017>
  at ICSharpCode.NRefactory.CSharp.CSharpParser.Parse (System.IO.Stream,string,int) <0x00033>
  at ICSharpCode.NRefactory.CSharp.CSharpParser.Parse (System.IO.TextReader,string,int) <0x000fb>
  at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngineBase.ParseStub (string,bool,string) <0x0023b>
  at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.GetExpressionAtCursor () <0x0001f>
  at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.MagicKeyCompletion (char,bool) <0x01777>
  at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.GetCompletionData (int,bool) <0x00063>
  at MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension.InternalHandleCodeCompletion (MonoDevelop.Ide.CodeCompletion.CodeCompletionContext,char,bool,int&) <0x0020b>
  at MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension.HandleCodeCompletion (MonoDevelop.Ide.CodeCompletion.CodeCompletionContext,char,int&) <0x00117>
  at MonoDevelop.Ide.Gui.Content.CompletionTextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00193>
  at MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x0001b>
  at MonoDevelop.Ide.Gui.Content.TextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00043>
  at MonoDevelop.CSharp.Formatting.CSharpTextEditorIndentation.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x008bf>
  at MonoDevelop.Ide.Gui.Content.TextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00043>
  at MonoDevelop.Ide.Gui.Content.TextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00043>
  at MonoDevelop.Ide.Gui.Content.TextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00043>
  at MonoDevelop.Ide.Gui.Content.TextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00043>
  at MonoDevelop.Ide.Gui.Content.TextEditorExtension.KeyPress (Gdk.Key,char,Gdk.ModifierType) <0x00043>
  at MonoDevelop.SourceEditor.ExtensibleTextEditor.ExtensionKeyPress (Gdk.Key,uint,Gdk.ModifierType) <0x0002d>
  at MonoDevelop.SourceEditor.ExtensibleTextEditor.OnIMProcessedKeyPressEvent (Gdk.Key,uint,Gdk.ModifierType) <0x00937>
  at Mono.TextEditor.TextEditor.IMCommit (object,Gtk.CommitArgs) <0x00165>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
  at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x00147>
  at System.Reflection.MethodBase.Invoke (object,object[]) <0x00022>
  at System.Delegate.DynamicInvokeImpl (object[]) <0x001c3>
  at System.MulticastDelegate.DynamicInvokeImpl (object[]) <0x00033>
  at System.Delegate.DynamicInvoke (object[]) <0x00016>
  at GLib.Signal.ClosureInvokedCB (object,GLib.ClosureInvokedArgs) <0x0012f>
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs) <0x00023>
  at GLib.SignalClosure.MarshalCallback (intptr,intptr,uint,intptr,intptr,intptr) <0x004eb>
  at (wrapper native-to-managed) GLib.SignalClosure.MarshalCallback (intptr,intptr,uint,intptr,intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) Gtk.IMContext.gtk_im_context_filter_keypress (intptr,intptr) <0xffffffff>
  at Gtk.IMContext.FilterKeypress (Gdk.EventKey) <0x0002b>
  at Mono.TextEditor.TextEditor.IMFilterKeyPress (Gdk.EventKey,Gdk.Key,uint,Gdk.ModifierType) <0x0005b>
  at Mono.TextEditor.TextEditor.OnKeyPressEvent (Gdk.EventKey) <0x002b3>
  at MonoDevelop.SourceEditor.ExtensibleTextEditor.OnKeyPressEvent (Gdk.EventKey) <0x0001f>
  at Gtk.Widget.keypressevent_cb (intptr,intptr) <0x00061>
  at (wrapper native-to-managed) Gtk.Widget.keypressevent_cb (intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) Gtk.Widget.gtksharp_widget_base_key_press_event (intptr,intptr) <0xffffffff>
  at Gtk.Widget.OnKeyPressEvent (Gdk.EventKey) <0x0002b>
  at MonoDevelop.Ide.Gui.DefaultWorkbench.OnKeyPressEvent (Gdk.EventKey) <0x001a3>
  at Gtk.Widget.keypressevent_cb (intptr,intptr) <0x00061>
  at (wrapper native-to-managed) Gtk.Widget.keypressevent_cb (intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) Gtk.Application.gtk_main () <0xffffffff>
  at Gtk.Application.Run () <0x0000b>
  at MonoDevelop.Ide.IdeApp.Run () <0x0000b>
  at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions) <0x01423>
  at MonoDevelop.Ide.IdeStartup.Main (string[]) <0x000e7>
  at MonoDevelop.Startup.MonoDevelopMain.Main (string[]) <0x00013>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff>
Comment 3 Mike Krüger 2012-07-06 07:53:22 UTC
Seems that the gui thread is waiting for a background thread to finish.
How long did you try to run it ?

Can you provide the whole project or file ?
Comment 4 tome 2012-07-06 11:37:40 UTC
Created attachment 2162 [details]
A MonoTouch Library project to reproduce the accident

It was just created as a C# MonoTouch Library project, then added one C# source file.
Comment 5 tome 2012-07-06 11:41:46 UTC
For a couple of miniutes (up to 5 mins) to run it and gave up.

Surely, I've attached a project file.
Comment 6 Mike Krüger 2012-07-09 08:50:11 UTC
Thanks for the test case - I can repro the issue now.

I tracked it down to an infinite loop in the c# parser - it's now fixed & reported upstream.