Bug 186 - Startup deadlock when running on .NET/Windows
Summary: Startup deadlock when running on .NET/Windows
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Windows
: --- blocker
Target Milestone: ---
Assignee: Lluis Sanchez
Depends on:
Reported: 2011-08-05 02:15 UTC by Atsushi Eno
Modified: 2011-08-16 04:57 UTC (History)
2 users (show)

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

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:

Description Atsushi Eno 2011-08-05 02:15:55 UTC
MonoDevelop from trunk is suffered from some deadlocks at startup. It does not proceed after showing "Startup MonoDevelop".

I debugged it on Visual Studio and figured that the deadlock occurs at MonoDevelop.Core.Assemblies.TargetRuntime.Initialize(). It tries to acquire a lock, but it won't succeed since BackgroundInitialize() already acquired lock (I see it passes twice) from different thread.

I have no idea why this does not happen on other platforms (possibly mono object monitoring is somewhat loose, or on Windows it runs through some different code).

This can be (kind of) workarounded like this:

		internal void Initialize ()
			/*lock (initLock) {
				while (!initialized) {
					Monitor.Wait (initLock);
			Thread.Sleep (5000);
Comment 1 Atsushi Eno 2011-08-05 02:55:23 UTC
Hmm, actually similar deadlocks - or something that looks like deadlock - occur all around e.g. when creating a new solution, or opening an existing solution.

Actually my attempt to create a new solution resulted in some weird PInvoke error like [*1], and by ignoring them I could see a new console project on the text editor, after couple of *minutes* (it is, it has slowly done the job).

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'MonoDevelop.Core!MonoDevelop.Projects.Text.TextFile::g_convert' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Comment 2 Lluis Sanchez 2011-08-16 04:57:19 UTC
Deadlock already fixed.