roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

DeferredProjectWorkspaceService needs update to do the filtering on IVsSolutionWorkspaceService.GetManagedCommandLineInfoAsync()

Open huizhonglong opened this issue 9 years ago • 2 comments

IVsSolutionWorkspaceService.GetManagedCommandLineInfoAsync() used to return a dictionary with only valid intellisense data (CommandLineArgs and TargetPath not null or emtpy); the key is the full project path.

For 15.3 Preview 2, we've made the change to return the ManagedCommandLineInfo for all projects in the solution, so that when Roslyn calls this API, it can filter and act upon the projects that don't have valid Intellisense data, e.g. trigger a full load of those projects. Please make sure do the valid check to avoid crash.

huizhonglong avatar May 10 '17 20:05 huizhonglong

This issue now makes d15prerel crash:

Version Used: Roslyn: 2.03.0.61724 VS: d15prerel 26529.03 Steps to Reproduce:

  1. Get DeferredLoadTestSolution solution from https://mseng.visualstudio.com/VSIDEProj/_git/VSIDEProj.SLNX.TestRepo
  2. Enable Lightweight Solution Load mode
  3. Open the solution

Expected Behavior: VS does not crash

Actual Behavior: VS crashes with NullReferenceException

Exception Callstack

>	Microsoft.VisualStudio.LanguageServices.Next.dll!Microsoft.VisualStudio.LanguageServices.ProjectSystem.DeferredProjectWorkspaceService.GetDeferredProjectInfoForConfigurationAsync.AnonymousMethod__2_0(System.Collections.Generic.KeyValuePair<string, Microsoft.VisualStudio.Workspace.Extensions.ManagedCommandLineInfo> kvp) Line 41	C#
 	System.Core.dll!System.Linq.Enumerable.WhereSelectEnumerableIterator<System.Collections.Generic.KeyValuePair<string, Microsoft.VisualStudio.Workspace.Extensions.ManagedCommandLineInfo>, System.Collections.Generic.KeyValuePair<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>>.MoveNext() Line 286	C#
 	System.Collections.Immutable.dll!System.Collections.Immutable.ImmutableDictionary<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>.AddRange(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>> items, System.Collections.Immutable.ImmutableDictionary<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>.MutationInput origin, System.Collections.Immutable.ImmutableDictionary<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>.KeyCollisionBehavior collisionBehavior) Line 992	C#
 	System.Collections.Immutable.dll!System.Collections.Immutable.ImmutableDictionary<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>.AddRange(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>> pairs, bool avoidToHashMap) Line 1106	C#
 	System.Collections.Immutable.dll!System.Collections.Immutable.ImmutableDictionary<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>.AddRange(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>> pairs) Line 319	C#
 	Microsoft.VisualStudio.LanguageServices.Next.dll!Microsoft.VisualStudio.LanguageServices.ProjectSystem.DeferredProjectWorkspaceService.GetDeferredProjectInfoForConfigurationAsync(string solutionConfiguration, System.Threading.CancellationToken cancellationToken) Line 40	C#
 	kernel32.dll!BaseThreadInitThunk(unsigned long RunProcessInit, long(__stdcall*)(void *) StartAddress, void * Argument) Line 64	C
 	ntdll.dll!__RtlUserThreadStart(long(__stdcall*)(void *) StartAddress, void * Argument) Line 997	C
 	ntdll.dll!_RtlUserThreadStart(long(__stdcall*)(void *) StartAddress, void * Argument) Line 914	C
 	[Resuming Async Method]	
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(object stateMachine)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()	Unknown
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()	Unknown
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()	Unknown
 	mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0()	Unknown
 	mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()	Unknown
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.ExecuteWorkItemHelper()	Unknown
 	mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()	Unknown
 	mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()	Unknown
 	mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()	Unknown
 	[Native to Managed Transition]	
 	[Async Call]	
 	Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.PopulateWorkspaceFromDeferredProjectInfoAsync(System.Threading.CancellationToken cancellationToken)	Unknown
 	[Async Call]	
 	Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.LoadSolutionFromMSBuildAsync()	Unknown
 	[Async Call]	
 	Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.TaskExtensions.FireAndForget(System.Threading.Tasks.Task task) Line 25	C#

There is this debug output

System.Transactions Critical: 0 : 
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical">
<TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier>
<Description>Unhandled exception</Description>
<AppDomain>DefaultDomain</AppDomain>
<Exception>
<ExceptionType>System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Object reference not set to an instance of an object.</Message>
<StackTrace>   
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.DeferredProjectWorkspaceService.&amp;lt;&amp;gt;c.&amp;lt;GetDeferredProjectInfoForConfigurationAsync&amp;gt;b__2_0(KeyValuePair`2 kvp)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.DeferredProjectWorkspaceService.&amp;lt;GetDeferredProjectInfoForConfigurationAsync&amp;gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.&amp;lt;PopulateWorkspaceFromDeferredProjectInfoAsync&amp;gt;d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.&amp;lt;LoadSolutionFromMSBuildAsync&amp;gt;d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Roslyn.Utilities.TaskExtensions.&amp;lt;FireAndForget&amp;gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.&amp;lt;&amp;gt;c.&amp;lt;ThrowAsync&amp;gt;b__6_0(Object state)
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.SingleExecuteProtector.TryExecute()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.SingleExecuteProtector.&amp;lt;&amp;gt;c.&amp;lt;.cctor&amp;gt;b__20_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp;amp; handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp;amp; handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)</StackTrace><ExceptionString>System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.DeferredProjectWorkspaceService.&amp;lt;&amp;gt;c.&amp;lt;GetDeferredProjectInfoForConfigurationAsync&amp;gt;b__2_0(KeyValuePair`2 kvp)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.DeferredProjectWorkspaceService.&amp;lt;GetDeferredProjectInfoForConfigurationAsync&amp;gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.&amp;lt;PopulateWorkspaceFromDeferredProjectInfoAsync&amp;gt;d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.&amp;lt;LoadSolutionFromMSBuildAsync&amp;gt;d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Roslyn.Utilities.TaskExtensions.&amp;lt;FireAndForget&amp;gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.&amp;lt;&amp;gt;c.&amp;lt;ThrowAsync&amp;gt;b__6_0(Object state)
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.SingleExecuteProtector.TryExecute()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.SingleExecuteProtector.&amp;lt;&amp;gt;c.&amp;lt;.cctor&amp;gt;b__20_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp;amp; handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp;amp; handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)</ExceptionString><DataItems><Data></Data></DataItems></Exception></TraceRecord>

IlyaBiryukov avatar May 30 '17 18:05 IlyaBiryukov

Typo in my PR means we didn't actually force load these projects.

Pilchie avatar Jun 07 '17 22:06 Pilchie