Bug 24550 - VS hangs while debugging
Summary: VS hangs while debugging
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 4.0.0 (C6)
Hardware: Macintosh Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-11-15 10:01 UTC by Ofir Makmal
Modified: 2016-12-22 21:22 UTC (History)
4 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 Ofir Makmal 2014-11-15 10:01:46 UTC
While debugging an iOS app in VS, and stepping into methods, Visual Studio hangs.

I've looked into it and its looks like that there is a race-condition while working concurrently on a Dictionary (System.__Canon,System.__Canon);

I have 4 cores, and VS stated to consume 75% of CPU constantly, so it looked like there are three threads that were consuming CPU time (as the UI is frozen, I assumed that the main thread is one of the three threads that got stuck).

Using Windbg, I've saw that the the CLR Stack of the main thread is the following:

0:000> !CLRStack
OS Thread Id: 0x1678 (0)
Child SP       IP Call Site
00bde294 727e3849 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].Insert(System.__Canon, System.__Canon, Boolean)
00bde2c8 1d03e331 Xamarin.VisualStudio.Debugger.ProjectVisualStudio.FindOrCreateDocument(System.String)
00bde2dc 1d03e2b6 Xamarin.VisualStudio.Debugger.ProjectVisualStudio.LoadFile(System.String)
00bde2e0 1d03e28c Xamarin.VisualStudio.Debugger.ProjectVisualStudio+<>c__DisplayClass4.<GetFiles>b__3(Int32)
00bde2ec 72ffab4f System.Threading.Tasks.Parallel+<>c__DisplayClassf`1[[System.__Canon, mscorlib]].<ForWorker>b__c()
00bde368 728004e5 System.Threading.Tasks.Task.InnerInvoke()
00bde374 72834a86 System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.Task)
00bde380 7280f217 System.Threading.Tasks.Task+<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(System.Object)
00bde3b0 72769e1c System.Threading.Tasks.Task.ExecuteSelfReplicating(System.Threading.Tasks.Task)
00bde3c0 72800497 System.Threading.Tasks.Task.Execute()
00bde3e4 72800419 System.Threading.Tasks.Task.ExecutionContextCallback(System.Object)
00bde3e8 727cdf17 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
00bde454 727cde66 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
00bde468 72800238 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
00bde4cc 72800157 System.Threading.Tasks.Task.ExecuteEntry(Boolean)
00bde4dc 72800f36 System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task, Boolean)
00bde508 72800e4c System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task, Boolean)
00bde54c 72769947 System.Threading.Tasks.Task.InternalRunSynchronously(System.Threading.Tasks.TaskScheduler, Boolean)
00bde594 727698b3 System.Threading.Tasks.Task.RunSynchronously(System.Threading.Tasks.TaskScheduler)
00bde5a0 72f0831d System.Threading.Tasks.Parallel.ForWorker[[System.__Canon, mscorlib]](Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>, System.Action`2<Int32,System.Threading.Tasks.ParallelLoopState>, System.Func`4<Int32,System.Threading.Tasks.ParallelLoopState,System.__Canon,System.__Canon>, System.Func`1<System.__Canon>, System.Action`1<System.__Canon>)
00bde658 72f07c9e System.Threading.Tasks.Parallel.For(Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>)
00bde674 1d03ddea Xamarin.VisualStudio.Debugger.ProjectVisualStudio.GetFiles(VSLangProj.VSProject)
00bde6a0 1ccd4a98 Xamarin.VisualStudio.Debugger.ProjectVisualStudio..ctor(VSLangProj.VSProject)
00bde6b8 1ccd496e Xamarin.VisualStudio.Debugger.ExpressionResolver.FindOrCreateDocument(System.String)
00bde6d4 1ccd488f Xamarin.VisualStudio.Debugger.ExpressionResolver.ResolveType(System.String, Mono.Debugging.Client.SourceLocation)
00bde6e8 1ccd4859 Xamarin.VisualStudio.Debugger.MonoToolsDebuggerSession.OnResolveType(System.String, Mono.Debugging.Client.SourceLocation)
00bde704 1ccd47d3 Mono.Debugging.Client.DebuggerSession.ResolveIdentifierAsType(System.String, Mono.Debugging.Client.SourceLocation)
00bde70c 1ccd46c2 Mono.Debugging.Evaluation.NRefactoryExpressionResolverVisitor.ReplaceType(System.String, Int32, Int32, Int32, Boolean)
00bde734 1ccd452b Mono.Debugging.Evaluation.NRefactoryExpressionResolverVisitor.VisitIdentifierExpression(ICSharpCode.NRefactory.CSharp.IdentifierExpression)
00bde770 1ccd442b ICSharpCode.NRefactory.CSharp.IdentifierExpression.AcceptVisitor(ICSharpCode.NRefactory.CSharp.IAstVisitor)
00bde778 18576b14 Mono.Debugging.Evaluation.NRefactoryExpressionEvaluator.Resolve(Mono.Debugging.Client.DebuggerSession, Mono.Debugging.Client.SourceLocation, System.String, Boolean)
00bde7ac 18576950 Mono.Debugging.Evaluation.NRefactoryExpressionEvaluator.Resolve(Mono.Debugging.Client.DebuggerSession, Mono.Debugging.Client.SourceLocation, System.String)
00bde7b8 18576926 Mono.Debugging.Client.DebuggerSession.OnResolveExpression(System.String, Mono.Debugging.Client.SourceLocation)
00bde7c8 18576811 Mono.Debugging.Client.DebuggerSession.ResolveExpression(System.String, Mono.Debugging.Client.SourceLocation)
00bde800 1857678c Mono.Debugging.Client.StackFrame.ValidateExpression(System.String, Mono.Debugging.Client.EvaluationOptions)
00bde81c 185766c5 Xamarin.VisualStudio.Debugger.StackFrame+ExpressionContext.Microsoft.VisualStudio.Debugger.Interop.IDebugExpressionContext2.ParseText(System.String, UInt32, UInt32, Microsoft.VisualStudio.Debugger.Interop.IDebugExpression2 ByRef, System.String ByRef, UInt32 ByRef)
00bde848 6785fb5d *** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.Vc5509e61#\2b884ea154b1f3ad8fc54bf4fe9d0faa\Microsoft.VisualStudio.Debugger.Interop.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.Vc5509e61#\2b884ea154b1f3ad8fc54bf4fe9d0faa\Microsoft.VisualStudio.Debugger.Interop.ni.dll
DomainNeutralILStubClass.IL_STUB_COMtoCLR(IntPtr, Int32, Int32, IntPtr, IntPtr, IntPtr)
00bde940 73612a79 [ComMethodFrame: 00bde940] 
00bded14 73612a79 [InlinedCallFrame: 00bded14] 
00bdecf8 69e31346 *** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V4c263b4e#\2d0a515635cf0091cb34df1540896c83\Microsoft.VisualStudio.TextManager.Interop.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V4c263b4e#\2d0a515635cf0091cb34df1540896c83\Microsoft.VisualStudio.TextManager.Interop.ni.dll
DomainNeutralILStubClass.IL_STUB_CLRtoCOM(Microsoft.VisualStudio.TextManager.Interop.TextSpan[], System.String ByRef)
00bded14 6181ecdd [InlinedCallFrame: 00bded14] Microsoft.VisualStudio.TextManager.Interop.IVsTextViewFilter.GetDataTipText(Microsoft.VisualStudio.TextManager.Interop.TextSpan[], System.String ByRef)
00bded90 6181ecdd *** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V60c407c8#\dce2cb732a106a8e7bdf7cb8f881d875\Microsoft.VisualStudio.Editor.Implementation.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V60c407c8#\dce2cb732a106a8e7bdf7cb8f881d875\Microsoft.VisualStudio.Editor.Implementation.ni.dll
Microsoft.VisualStudio.Editor.Implementation.ShimQuickInfoSource.TryGetQuickInfoFromFilter(Microsoft.VisualStudio.Language.Intellisense.IQuickInfoSession, Microsoft.VisualStudio.TextManager.Interop.TextSpan[], System.String ByRef)
00bdedac 6181ec15 Microsoft.VisualStudio.Editor.Implementation.ShimQuickInfoSource.AugmentQuickInfoSession(Microsoft.VisualStudio.Language.Intellisense.IQuickInfoSession, System.Collections.Generic.IList`1<System.Object>, Microsoft.VisualStudio.Text.ITrackingSpan ByRef)
00bdee80 6125b2a3 *** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V0c1ea960#\af1f435fe48a10cbbe53904d7934ce23\Microsoft.VisualStudio.Platform.VSEditor.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V0c1ea960#\af1f435fe48a10cbbe53904d7934ce23\Microsoft.VisualStudio.Platform.VSEditor.ni.dll
Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoSession.Recalculate()
00bdeefc 6125b1b8 Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoSession.Start()
00bdef08 6125c36c Microsoft.VisualStudio.Language.Intellisense.Implementation.DefaultQuickInfoController.OnTextView_MouseHover(System.Object, Microsoft.VisualStudio.Text.Editor.MouseHoverEventArgs)
00bdef4c 6125afa7 Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.RaiseHoverEvents()
00bdefac 6125ad87 Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.OnHoverTimer(System.Object, System.EventArgs)
00bdefc0 6fd75a5f *** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\WindowsBase\b8e2e79f70d09551560548cda72e2c51\WindowsBase.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\WindowsBase\b8e2e79f70d09551560548cda72e2c51\WindowsBase.ni.dll
System.Windows.Threading.DispatcherTimer.FireTick(System.Object)
00bdefd0 6fd78192 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
00bdeff0 6fd780ca MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
00bdf034 6fd7a7ac System.Windows.Threading.DispatcherOperation.InvokeImpl()
00bdf06c 6fd7a6f8 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
00bdf074 727cdf17 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
00bdf0e0 727cde66 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
00bdf0f4 727cde31 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
00bdf10c 6fd7a61b System.Windows.Threading.DispatcherOperation.Invoke()
00bdf144 6fd76f9b System.Windows.Threading.Dispatcher.ProcessQueue()
00bdf188 6fd7713a System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
00bdf1d4 6fd7837b MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
00bdf210 6fd782cb MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
00bdf220 6fd78192 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
00bdf240 6fd780ca MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
00bdf284 6fd7686e System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
00bdf2d8 6fd77c51 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)


FindOrCreateDocument is trying to add item to a Dictionary concurrently from three different threads.
Xamarin.VisualStudio.Debugger.ProjectVisualStudio.GetFiles methods is using Parallel.For method.

To make sure that there are three threads that are stuck in the same method, i've run the following command:
0:000> .shell -ci "~*e !clrstack" FINDSTR System.Collections.Generic.Dictionary
00bde294 727e3849 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].Insert(System.__Canon, System.__Canon, Boolean)
30f3ec84 727e3849 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].Insert(System.__Canon, System.__Canon, Boolean)
37ffec14 727e3854 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].Insert(System.__Canon, System.__Canon, Boolean)
.shell: Process exited

This is a known phenomenon when trying to work concurrently with a dictionary without proper synchronization in place.

Thanks,
Ofir Makmal
Comment 1 Arpit Jha 2014-12-15 03:58:11 UTC
I have checked this issue and unable to reproduce it with the help of bug description.

I observed that I am able to build and deploy and ios application on physical device and simulator successfully as shown in screencast:http://www.screencast.com/t/2rQCOvBPPNq

Could you please provide us Build Info,Ide log,VS Trace logs ? 
Ide log-> In VS Help-> Zipped Xamarin Logs.
VS Trace log -> In Mac User Library-> Logs->Xamarin->MonoTouch VS

Please let me know if I missed anything to reproduce this issue ?

We are getting VS hangs only in one case when device is not added to the provisioning profile ? Could you please confirm that device is added to provisioning profile or not if you are running your ios app on physical device 
as shown in screencast: http://www.screencast.com/t/ghcy9WLltn

Environment Info:
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.53344

Installed Version: Professional

Xamarin   3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Xamarin.Android   4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Xamarin.iOS   8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)
Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified 
XI  8.4.0.43
Build Host: 3.8.0.145
Comment 2 Jose Gallardo 2016-12-22 21:22:21 UTC
Hi,
As we've introduced several improvements around VS/Mac connectivity and the iOS build and debugging system, I'll mark the bug as resolved fixed.
Please feel free to reopen it if you can still reproduce the issue with current bits.
Thanks!