tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
561 stars 97 forks source link

Crash on 'Go To All' #170

Closed Reedbeta closed 4 years ago

Reedbeta commented 5 years ago

Opening the 'Go To All' window (Ctrl+comma) in an HLSL file and typing something will usually crash Visual Studio within a few seconds.

Reedbeta commented 4 years ago

I got a callstack for this crash:

>   ShaderTools.CodeAnalysis.Features.dll!ShaderTools.CodeAnalysis.NavigateTo.NavigateToSearchService.SearchDocumentAsync(ShaderTools.CodeAnalysis.Document document, string searchPattern, System.Threading.CancellationToken cancellationToken) Line 38   C#
    ShaderTools.CodeAnalysis.EditorFeatures.dll!ShaderTools.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.Searcher.SearchAsyncWorker(ShaderTools.CodeAnalysis.Document document) Line 116    C#
    ShaderTools.CodeAnalysis.EditorFeatures.dll!ShaderTools.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.Searcher.SearchAsync(ShaderTools.CodeAnalysis.Document document)   C#
    ShaderTools.CodeAnalysis.EditorFeatures.dll!ShaderTools.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.Searcher.Search() Line 83  C#
    ShaderTools.CodeAnalysis.EditorFeatures.dll!ShaderTools.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.StartSearch(Microsoft.VisualStudio.Language.NavigateTo.Interfaces.INavigateToCallback callback, string searchValue) Line 68    C#

It stopped on this if-statement in NavigateToSearchService.SearchDocumentAsync:

if (declaredSymbol != null 
    && declaredSymbol.Kind != SymbolKind.Parameter
    && (declaredSymbol.Kind != SymbolKind.Variable || declaredSymbol.Parent == null || declaredSymbol.Parent.Kind != SymbolKind.Function)
    && Contains(declaredSymbol.Name, searchPattern))

It looks like the problem is declaredSymbol.Name is null. The symbol in question is a Technique, and we do have many un-named techniques in our codebase. Should be easy to fix, just check for Name to be non-null.

tgjones commented 4 years ago

Fixed by #176.