Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard crash and/or gold bars when editing a file that contains aliases to pointer types #67989

Closed
jhinder opened this issue Apr 26, 2023 · 5 comments · Fixed by #68037
Closed
Assignees
Milestone

Comments

@jhinder
Copy link
Contributor

jhinder commented Apr 26, 2023

Version Used: VS 17.6 Preview 5

Steps to Reproduce:
Perform some IDE operations (typing, saving, etc) in this code file:

using unsafe Alias = int*;

namespace N
{
    internal unsafe class C
    {
        const int Factor = 3;

        void M()
        {
            _ = Alias * Factor;
        }
    }
}

Expected Behavior: No crash, no exceptions

Actual Behavior:
The first time devenv crashed with an exception. This was not reproducible, however the reproduction attempts led to several gold bars.

Crash log from `eventvwr`
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
   at Microsoft.CodeAnalysis.CSharp.Binder.BindNonMethod(Microsoft.CodeAnalysis.CSharp.Syntax.SimpleNameSyntax, Microsoft.CodeAnalysis.CSharp.Symbol, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Microsoft.CodeAnalysis.CSharp.LookupResultKind, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindIdentifier(Microsoft.CodeAnalysis.CSharp.Syntax.SimpleNameSyntax, Boolean, Boolean, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindSimpleBinaryOperator(Microsoft.CodeAnalysis.CSharp.Syntax.BinaryExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindAssignment(Microsoft.CodeAnalysis.CSharp.Syntax.AssignmentExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag, Boolean, Boolean)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionStatement(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, Boolean, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag)
   at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel+IncrementalBinder.BindStatement(Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax, Microsoft.CodeAnalysis.CSharp.BindingDiagnosticBag)
   at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode)
   at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode ByRef, Microsoft.CodeAnalysis.CSharp.BoundNode ByRef, Microsoft.CodeAnalysis.CSharp.BoundNode ByRef, Microsoft.CodeAnalysis.CSharp.BoundNode ByRef)
   at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetSymbolInfoWorker(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, SymbolInfoOptions, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetSymbolInfoWorker(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, SymbolInfoOptions, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfo(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.CSharp.Classification.OperatorOverloadSyntaxClassifier.AddClassifications(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.SemanticModel, Microsoft.CodeAnalysis.Classification.ClassificationOptions, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Classification.ClassifiedSpan>, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService+Worker.ClassifyNode(Microsoft.CodeAnalysis.SyntaxNode)
   at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService+Worker.ProcessNodes()
   at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService+Worker.Classify(Microsoft.CodeAnalysis.SemanticModel, Microsoft.CodeAnalysis.Text.TextSpan, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Classification.ClassifiedSpan>, System.Func`2<Microsoft.CodeAnalysis.SyntaxNode,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Classification.Classifiers.ISyntaxClassifier>>, System.Func`2<Microsoft.CodeAnalysis.SyntaxToken,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Classification.Classifiers.ISyntaxClassifier>>, Microsoft.CodeAnalysis.Classification.ClassificationOptions, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.AddSemanticClassifications(Microsoft.CodeAnalysis.SemanticModel, Microsoft.CodeAnalysis.Text.TextSpan, System.Func`2<Microsoft.CodeAnalysis.SyntaxNode,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Classification.Classifiers.ISyntaxClassifier>>, System.Func`2<Microsoft.CodeAnalysis.SyntaxToken,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Classification.Classifiers.ISyntaxClassifier>>, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Classification.ClassifiedSpan>, Microsoft.CodeAnalysis.Classification.ClassificationOptions, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.Classification.Classifier.GetClassifiedSpans(Microsoft.CodeAnalysis.Host.SolutionServices, Microsoft.CodeAnalysis.Project, Microsoft.CodeAnalysis.SemanticModel, Microsoft.CodeAnalysis.Text.TextSpan, Microsoft.CodeAnalysis.Classification.ClassificationOptions, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.Classification.Classifier.GetClassifiedSpans(Microsoft.CodeAnalysis.SemanticModel, Microsoft.CodeAnalysis.Text.TextSpan, Microsoft.CodeAnalysis.Workspace, System.Threading.CancellationToken)
   at Roslyn.SyntaxVisualizer.Control.SyntaxVisualizerControl.DisplaySyntaxTree(Microsoft.CodeAnalysis.SyntaxTree, Microsoft.CodeAnalysis.SemanticModel, Boolean, Microsoft.CodeAnalysis.Workspace)
   at Roslyn.SyntaxVisualizer.Extension.SyntaxVisualizerContainer.RefreshSyntaxVisualizer()
   at System.Windows.Threading.DispatcherTimer.FireTick(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.DispatcherOperation.InvokeImpl()
   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)
Exception from gold bar
StreamJsonRpc.RemoteInvocationException: Unexpected value 'PointerType' of type 'Microsoft.CodeAnalysis.SymbolKind'
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__151`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__20`1.MoveNext()
RPC server exception:
System.InvalidOperationException: Unexpected value 'PointerType' of type 'Microsoft.CodeAnalysis.SymbolKind'
      at Microsoft.CodeAnalysis.CSharp.Binder.BindNonMethod(SimpleNameSyntax node, Symbol symbol, BindingDiagnosticBag diagnostics, LookupResultKind resultKind, Boolean indexed, Boolean isError)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindIdentifier(SimpleNameSyntax node, Boolean invoked, Boolean indexed, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindSimpleBinaryOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindAssignment(AssignmentExpressionSyntax node, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionStatement(CSharpSyntaxNode node, ExpressionSyntax syntax, Boolean allowsAnyExpression, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionStatement(ExpressionStatementSyntax node, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.IncrementalBinder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.Bind(Binder binder, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(CSharpSyntaxNode node)
      at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetLowerBoundNode(CSharpSyntaxNode node)
      at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(CSharpSyntaxNode node, CSharpSyntaxNode& bindableNode, BoundNode& lowestBoundNode, BoundNode& highestBoundNode, BoundNode& boundParent)
      at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfo(ExpressionSyntax expression, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(SyntaxNode node, CancellationToken cancellationToken)
      at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
      at Microsoft.CodeAnalysis.FindSymbols.FindReferenceCache.GetSymbolInfo(SyntaxNode node, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.FindSymbols.Finders.AbstractReferenceFinder.FindReferencesInTokensAsync(ISymbol symbol, FindReferencesDocumentState state, ImmutableArray`1 tokens, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.FindSymbols.Finders.AbstractReferenceFinder.FindReferencesInDocumentUsingIdentifierAsync(ISymbol symbol, String identifier, FindReferencesDocumentState state, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.FindSymbols.Finders.FieldSymbolReferenceFinder.FindReferencesInDocumentAsync(IFieldSymbol symbol, FindReferencesDocumentState state, FindReferencesSearchOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass28_0.<<FindReferencesInDocumentsAsync>g__PerformSearchInDocumentWorkerAsync|4>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass28_0.<<FindReferencesInDocumentsAsync>g__PerformSearchInDocumentAsync|3>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass28_0.<<FindReferencesInDocumentsAsync>g__PerformSearchInProjectAsync|2>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesInDocumentsAsync(ISymbol originalSymbol, IImmutableSet`1 documents, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetTagsForReferencedSymbolAsync(ISymbol symbol, Document document, IImmutableSet`1 documentsToSearch, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetDocumentHighlightsInCurrentProcessAsync(Document document, Int32 position, IImmutableSet`1 documentsToSearch, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetDocumentHighlightsAsync(Document document, Int32 position, IImmutableSet`1 documentsToSearch, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDocumentHighlightsService.<>c__DisplayClass2_0.<<GetDocumentHighlightsAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass9_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Int32 workspaceVersion, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Int32 workspaceVersion, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunServiceImplAsync[T](Func`2 implementation, CancellationToken cancellationToken)

Relates to alias any type: #56323

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 26, 2023
@sharwell
Copy link
Member

SyntaxVisualizerControl

This one should be reported/fixed in dotnet/roslyn-sdk.

@jcouv
Copy link
Member

jcouv commented Apr 28, 2023

@sharwell I see that you fixed something in SyntaxVisualizerControl that relates to this issue. Can we close this?

@jhinder
Copy link
Contributor Author

jhinder commented Apr 28, 2023

@jcouv The fix by @sharwell relates only to the Syntax Visualizer and prevents the exception from bubbling up and taking down the entire IDE, right? The underlying exception thrown by the compiler (that also causes all the gold bars) is still there.

@sharwell
Copy link
Member

Yes that's correct

@jcouv jcouv added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 28, 2023
@jcouv
Copy link
Member

jcouv commented Apr 28, 2023

Assigned to @CyrusNajmabadi. Looks like an issue with semantic model on alias to pointer type. Let me know if you need help with setting up unittest to repro this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants