Bug 18138 - XamarinStudio Crashes when editing Razor view
Summary: XamarinStudio Crashes when editing Razor view
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: 4.2.x
Hardware: Macintosh Mac OS
: High normal
Target Milestone: master
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2014-03-03 17:38 UTC by Johannes
Modified: 2014-05-19 19:25 UTC (History)
2 users (show)

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


Attachments
IDE log file (279.41 KB, application/octet-stream)
2014-04-05 19:21 UTC, Brett Ernst
Details
IDE log with thread dump (9.33 KB, text/plain)
2014-05-01 11:55 UTC, Bojan Rajkovic [MSFT]
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 Johannes 2014-03-03 17:38:20 UTC
I am working with OS X Mavericks, XamarinStudio 4.2.3 and With ASP.NET MVC 5.1

While creating an @ActionLink() in a strongly typed Razor View (with no other content) XamarinStudio chrashs. I had to Force Quit the Studio and reopen it, as I tried again also the error occurred. After 3-4 times in a Moment of happiness I've been able to complete the command. 

The system I which I've been able to reproduce it, consists of three classes, maybe this helps:

The View (The Harbour Class consists just of a number of Properties with String and int values, and one special Type called GeoPosition):

@model List<portGuide.Domain.Harbour>

	@foreach(var v in Model) {
		<li>@Html.ActionLink(v.Name,"Details", v.Id)</li>
	}

The Model class:

using System;

namespace portGuide.Domain
{
	/// <summary>
	/// Defines a Harbour/Port Entity, 
	/// </summary>
	public class Harbour
	{
		private int _id;
		private String _name;
		private String _description;
		private geoPosition _location;
		private Double _rating;


		public Harbour ()
		{
		}

		public int Id {
			get {
				return _id;
			}
			set {
				_id = value;
			}
		}

		public String Name {
			get {
				return _name;
			}
			set {
				_name = value;
			}
		}

		public String Description {
			get {
				return _description;
			}
			set {
				_description = value;
			}
		}


		public geoPosition Location {
			get {
				return _location;
			}
			set {
				_location = value;
			}
		}
	}
}


The GeoPosition:

using System;

namespace portGuide.Domain
{
	/// <summary>
	/// Geo position is a value type.
	/// </summary>
	public class geoPosition
	{
		private Double _lat;
		private Double _lon;

		private geoPosition (Double lat, Double lon)
		{
			_lat = lat;
			_lon = lon;
		}

		public geoPosition valueOf(Double lat, Double lon)
		{
			return new geoPosition (lat, lon);
		}

		public Double Latitude {
			get {
				return _lat;
			}
			set {
				_lat = value;
			}
		}

		public Double Longitude {
			get {
				return _lon;
			}
			set {
				_lon = value;
			}
		}

		public String toString(){
			return _lat + " " + _lon;
		}

	}
}
Comment 1 Mikayla Hutchinson [MSFT] 2014-03-03 18:35:21 UTC
When XS hangs, can you please run this command in a terminal:

killall -QUIT XamarinStudio

This will cause XS to write stack traces of all its threads to its log file. Then, please find the log file from Help -> Open Log Directory, and attach it.
Comment 2 Brett Ernst 2014-04-05 19:20:20 UTC
I'd like to update this bug as I believe it may be the same one I'm encountering. Frequently, when editing a razor view, Xamarin Studio will hang. This always occurs while typing, and frequently seems to occur at points where intellisense or auto-formatting might occur - for example, when accessing object properties by typing a dot, or accessing an indexer by typing an open bracket.

In some cases, the IDE hangs forever, while in other cases it can recover in varying amounts of time (15 to 60 seconds, I'd say).

I'm using 4.2.3 under OSX Mavericks. This seems to occur on all projects with razor views.

I sent a QUIT signal to the IDE while it was hung and I've attached the logs. As you can imagine, this makes editing views very difficult, so please let me know if I can provide more info.
Comment 3 Brett Ernst 2014-04-05 19:21:19 UTC
Created attachment 6503 [details]
IDE log file
Comment 4 Mikayla Hutchinson [MSFT] 2014-04-06 14:02:37 UTC
GUI thread is blocked in C# completion code:

  at MonoDevelop.Refactoring.ExtensionMethods/TaskWrapper.get_Result () [0x0001f] in main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ExtensionMethods.cs:58
  at MonoDevelop.CSharp.Refactoring.CodeActions.MDRefactoringContext.Create (MonoDevelop.Ide.Gui.Document,ICSharpCode.NRefactory.TextLocation,System.Threading.CancellationToken) [0x00016] in main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeActions/MDRefactoringContext.cs:197
  at MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension.InternalHandleCodeCompletion (MonoDevelop.Ide.CodeCompletion.CodeCompletionContext,char,bool,int&) [0x00126] in main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs:352
  at MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension.HandleCodeCompletion (MonoDevelop.Ide.CodeCompletion.CodeCompletionContext,char,int&) [0x00075] in main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs:274
  at MonoDevelop.AspNet.Mvc.Completion.RazorCSharpCompletionBuilder.HandleCompletion (MonoDevelop.Ide.Gui.Document,MonoDevelop.Ide.CodeCompletion.CodeCompletionContext,MonoDevelop.AspNet.Mvc.Completion.UnderlyingDocumentInfo,char,int&) [0x00012] in /main/src/addins/AspNet/MonoDevelop.AspNet.Mvc/Completion/RazorCSharpCompletionBuilder.cs:90
Comment 5 Mikayla Hutchinson [MSFT] 2014-04-19 13:22:36 UTC
.
Comment 6 Brett Ernst 2014-04-20 14:30:31 UTC
Please let me know if there's any way I can help with this issue. It is actually really crippling, as it crashes XS sometimes dozens of times a day. I didn't see a way to turn off code completion in razor views, so our devs are resorting to using external text editors, which is less than ideal.
Comment 7 Bojan Rajkovic [MSFT] 2014-05-01 11:55:29 UTC
Created attachment 6696 [details]
IDE log with thread dump

Running into the same issue here. Attaching a full log file, including a thread dump from `kill -QUIT` on the Mono process.
Comment 8 Mikayla Hutchinson [MSFT] 2014-05-19 19:25:25 UTC
Not sure why the shared resolver wasn't returning, but I fixed the C# completion code to use continuations instead of deadlocking by starving the task scheduler with blocking tasks.

https://github.com/mono/monodevelop/commit/976a93ee2be594ff1907d2b4702be7b34f843c21