This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Visual Studio crashes when pasting number ending with space into PR search box #1948
Copy link
Copy link
Closed
Description
Version
- GitHub Extension for Visual Studio version: 2.5.6 (dev)
- Visual Studio version: 2017
What happened
Steps to Reproduce
- Open GitHub based solution in Visual Studio
- Open
GitHubpane - Paste a number with trailing white-space into search box (e.g "156 ")
- Visual Studio crashes and quits
Log file:
The Windows Event Viewer contains the following under Application > .NET Runtime:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
at Microsoft.VisualStudio.Platform.WindowManagement.WindowSearchHost.StartSearch(Microsoft.VisualStudio.Shell.Interop.IVsSearchQuery, System.Action)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowSearchHost+<>c__DisplayClass42_0.<SearchAsync>b__0()
at Microsoft.VisualStudio.Shell.ThreadHelper.Invoke(System.Action)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowSearchHost.SearchAsync(Microsoft.VisualStudio.Shell.Interop.IVsSearchQuery)
at GitHub.VisualStudio.UI.GitHubPane.UpdateSearchHost(Boolean, System.String)
at GitHub.VisualStudio.UI.GitHubPane.<set_View>b__6_2(System.Tuple`2<Boolean,System.String>)
at System.Reactive.AnonymousSafeObserver`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnNext(System.__Canon)
at System.Reactive.ScheduledObserver`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Object, System.Action`1<System.Object>)
at System.Reactive.Concurrency.Scheduler+<>c__DisplayClass65_0`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<InvokeRec1>b__0(System.__Canon)
at System.Reactive.Concurrency.Scheduler.InvokeRec1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Reactive.Concurrency.IScheduler, Pair`2<System.__Canon,System.Action`2<System.__Canon,System.Action`1<System.__Canon>>>)
at System.Reactive.Concurrency.DispatcherScheduler+<>c__DisplayClass12_0`1[[System.Reactive.Concurrency.Scheduler+Pair`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=62aa029873c516b4]].<Schedule>b__0()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(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.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
VisualStudio/src/GitHub.VisualStudio/UI/GitHubPane.cs
Lines 166 to 177 in fdca558
| void UpdateSearchHost(bool enabled, string query) | |
| { | |
| if (SearchHost != null) | |
| { | |
| SearchHost.IsEnabled = enabled; | |
| if (SearchHost.SearchQuery?.SearchString != query) | |
| { | |
| SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null); | |
| } | |
| } | |
| } |
Research
Replacing the above method with the following appears to fix the crash.
void UpdateSearchHost(bool enabled, string query)
{
if (SearchHost != null)
{
SearchHost.IsEnabled = enabled;
var searchString = SearchHost.SearchQuery?.SearchString;
if (searchString?.Trim() != query?.Trim())
{
SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null);
}
}
}Here is Microsoft.VisualStudio.Platform.WindowManagement.WindowSearchHost.SearchAsync from Microsoft.VisualStudio.Platform.WindowManagement, Version=15.0.0.0:
I noticed that searchString is often "" rather than null. This causes SearchAsync to be cleared multiple times in a row. I don't know if this is potentially an issue. It doesn't cause crashes anyway!
Reactions are currently unavailable


Activity