Bug 45346 - VS 2015 crashing when Xamarin loses contact with Mac. Probably.
Summary: VS 2015 crashing when Xamarin loses contact with Mac. Probably.
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Xamzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-13 02:39 UTC by Xamzilla
Modified: 2016-12-20 18:02 UTC (History)
5 users (show)

Tags:
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 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 Xamzilla 2016-10-13 02:39:15 UTC
1. You guys force WAY too specific choices in bug entry. How would I know which of your components is failing? I make my best guess and move on. You need to provide "I have no idea/Other" choices any time you make us choose from a list.
2. I won't have direct repro steps for you. I'm going to tell you what I think I see happening when it crashes, and I'm going to give you a stack trace.

Sometimes when I have VS 2015 open to a Xamarin-Forms project containing an iOS project (XF Portable template, typically), and my Macintosh connected by network, after a period of inactivity VS 2015 crashes (we'll call this crashPrime). VS will restart and claim that "VS was restarted after an update was installed" (which does not appear to be true, I can never find evidence of an update), and offers to attempt to recover the file whose edits it just lost.

After this restart, VS will soon start sporadically crash and restart. Examining the Event Viewer indicates that all of these crashes (crashPrime plus all subsequent crashes)are Unhandled Exceptions in Xamarin's connect-to-mac code.

I cannot verify this, but the first crash (and almost definitely the subsequent crashes) seem to occur when the Mac is trying to go to sleep, or putting its hard drive to sleep, or waking itself up. However, this could be coincidence.

Also: I have NEVER seen this behaivor when I don't have the Mac connected. This is my default state, so the fact that it only happens when the Mac is connected seems unlikely to be a coincedence. Also, the stacktraces are all about ssh and connectivity.

Here are the stacktraces from the Event Viewer. The first stacktrace will be for crashPrime, and then I'll include two or three from the post-crashPrime crashes, which are slightly different.

crashPrime (time 6:04 PM, after VS/PC/Mac have all sat idle for two hours)

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisposeAsync>d__38.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisconnectAsync>d__36.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<OnMessagingConnectionDisconnected>d__40.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1(System.Object)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

And always, immediately above any of these crashes is this event:

Faulting application name: devenv.exe, version: 14.0.25420.1, time stamp: 0x57685d85
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x112c94ca
Faulting process id: 0x27b0
Faulting application start time: 0x01d223e888577b01
Faulting application path: E:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
Faulting module path: unknown
Report Id: 537eaaf2-6cce-43c9-9124-a611e7c9f3dc
Faulting package full name: 
Faulting package-relative application ID: 

[Visual Studio restarts itself, offers to restore my unsaved file]
[I start coding again, but have done no builds...]

crashPrime+1 (6:19 PM) - very similar stack

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisposeAsync>d__38.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisconnectAsync>d__36.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<OnSshClientDisconnected>d__39.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1(System.Object)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

[VS 2015 restarts itself, this time makes no excuses about updates, has lost my edits]
[I start recoding my lost edits]

crashPrime+2 (6:42 PM) - very different stacktrace

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Renci.SshNet.Common.SshConnectionException
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.Connect()
   at Xamarin.Messaging.Client.Ssh.MessagingScpClient.InitializeInnerClient()
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection.<.ctor>b__14_2()
   at System.Lazy`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].CreateValue()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Lazy`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Value()
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisposeAsync>d__38.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisconnectAsync>d__36.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<OnSshClientDisconnected>d__39.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1(System.Object)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

[VS restarts, again no offer to recover my lost edits. I yell and scream]
Comment 1 Xamzilla 2016-10-13 02:44:09 UTC
Note that the initial crash generally happens when I am not using VS directly, but the subsequent ones happen while I am coding. Although I am not doing builds, I suspect that Intellisense is doing background partial builds while I am changing code, and that is causing PC-to-Mac connectivity, which is throwing up.
Comment 2 Alexandre Defalque 2016-10-19 06:57:24 UTC
We have exactly the same problem in our team since we recently to Visual Studio 2015.
Random crash with the following stack in the event viewer:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisposeAsync>d__38.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at Xamarin.Messaging.Client.Ssh.SshMessagingConnection+<DisconnectAsync>d__36.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)


Using latest version of Xamarin for VS: 4.2.0.703

It seems there is already a ticket opened for this: https://bugzilla.xamarin.com/show_bug.cgi?id=41918
But it doesn't seem to be fixed.

This is really critical. Like Xamzilla said, we lose all our edits when it occurs.
Comment 3 mag@xamarin.com 2016-12-20 18:02:41 UTC
Hi,

Both VS and Mac logs are more helpful than pure Event Viewer stack traces.

You can find VS logs here in Windows: %LOCALAPPDATA%\Xamarin\Logs\<VsVersion>
Also, you can find XMA logs here in Mac: ~/Library/Logs/Xamarin.X.X

Alternatively and to avoid manually getting the logs, you can do from VS: Help > Xamarin > Zip Logs...

The last option will get both Windows and Mac logs corresponding to the current VS session. Of course, Mac logs will be retrieved only if you are connected to the Mac. If not and if you need Mac logs somehow, you can still get them manually.

Another helpful tip is to start VS in log mode, when you want to see more verbosity in the logs. To do that, just do: devenv.exe /log to launch VS.

Now, related to the exceptions itself, those are exceptions coming from our SSH layer in charge of establishing the secure connections to the Mac. According to the stack traces, those errors should be fixed in the last Alpha versions. You can get the latest one published on 19th Dec, which is 4.3.0.490.

By now I mark the bug as Resolved. 
Please let us know if you continue having connection errors and remember to attach the corresponding logs.

Thanks,
Mauro