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

NullReferenceException in MethodSymbol.get_ParameterCount() #73022

Open
vsfeedback opened this issue Apr 15, 2024 · 3 comments
Open

NullReferenceException in MethodSymbol.get_ParameterCount() #73022

vsfeedback opened this issue Apr 15, 2024 · 3 comments
Assignees
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] [regression] [worked-in:The one before 17.9.6]
I'm getting internal errors that impact syntax highlighting. It seems to be internal errors, possibly related to the recent updates. I can't do any coding as I can't trace references.


Original Comments

Feedback Bot on 4/11/2024, 08:54 PM:

(private comment, text removed)


Original Solutions

(no solutions)

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

Feature 'Missing import discovery' is currently unavailable due to an internal error.
StreamJsonRpc.RemoteInvocationException: Object reference not set to an instance of an object.
   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 System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__22`1.MoveNext()
RPC server exception:
System.NullReferenceException: Object reference not set to an instance of an object.
      at Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.get_ParameterCount()
      at Microsoft.CodeAnalysis.CSharp.InMethodBinder.LookupSymbolsInSingleBinder(LookupResult result, String name, Int32 arity, ConsList`1 basesBeingResolved, LookupOptions options, Binder originalBinder, Boolean diagnose, CompoundUseSiteInfo`1& useSiteInfo)
      at Microsoft.CodeAnalysis.CSharp.Binder.LookupSymbolsInternal(LookupResult result, String name, Int32 arity, ConsList`1 basesBeingResolved, LookupOptions options, Boolean diagnose, CompoundUseSiteInfo`1& useSiteInfo)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindNonGenericSimpleNamespaceOrTypeOrAliasSymbol(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics, ConsList`1 basesBeingResolved, Boolean suppressUseSiteDiagnostics, NamespaceOrTypeSymbol qualifierOpt)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindNamespaceOrTypeOrAliasSymbol(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList`1 basesBeingResolved, Boolean suppressUseSiteDiagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.BindTypeOrAlias(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList`1 basesBeingResolved, Boolean suppressUseSiteDiagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.AnalyzeAnonymousFunction(AnonymousFunctionExpressionSyntax syntax, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Binder.IdentifierUsedAsValueFinder.CheckLambda(AnonymousFunctionExpressionSyntax lambdaSyntax, Binder enclosingBinder)
      at Microsoft.CodeAnalysis.CSharp.Binder.IdentifierUsedAsValueFinder.CheckIdentifiersInNode(CSharpSyntaxNode node, Binder binder)
      at Microsoft.CodeAnalysis.CSharp.Binder.CapturedParametersFinder.<GetCapturedParameters>g__checkParameterReferencesInMethodBody|4_2(CSharpSyntaxNode syntaxNode, Binder bodyBinder, <>c__DisplayClass4_0&)
      at Microsoft.CodeAnalysis.CSharp.Binder.CapturedParametersFinder.GetCapturedParameters(SynthesizedPrimaryConstructor primaryConstructor)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SynthesizedPrimaryConstructor.GetCapturedParameters()
      at Microsoft.CodeAnalysis.CSharp.Symbols.SynthesizedPrimaryConstructor.GetBackingFields()
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.AddSynthesizedTypeMembersIfNecessary(MembersAndInitializersBuilder builder, DeclaredMembersAndInitializers declaredMembersAndInitializers, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.AddSynthesizedMembers(MembersAndInitializersBuilder builder, DeclaredMembersAndInitializers declaredMembersAndInitializers, BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.BuildMembersAndInitializers(BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersAndInitializers()
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.MakeAllMembers(BindingDiagnosticBag diagnostics)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersByNameSlow()
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbol.ForceCompleteMemberByLocation(SourceLocation locationOpt, Symbol member, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamespaceSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbol.ForceCompleteMemberByLocation(SourceLocation locationOpt, Symbol member, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamespaceSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbol.ForceCompleteMemberByLocation(SourceLocation locationOpt, Symbol member, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamespaceSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceModuleSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.Symbols.SourceAssemblySymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSourceDeclarationDiagnostics(SyntaxTree syntaxTree, Nullable`1 filterSpanWithinTree, Func`4 locationFilterOpt, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDiagnosticsForSyntaxTree(CompilationStage stage, SyntaxTree syntaxTree, Nullable`1 filterSpanWithinTree, Boolean includeEarlierStages, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetDiagnostics(Nullable`1 span, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.AddImport.AbstractAddImportFeatureService`1.GetUniqueFixesAsyncInCurrentProcessAsync(Document document, TextSpan span, ImmutableArray`1 diagnosticIds, ISymbolSearchService symbolSearchService, AddImportOptions options, ImmutableArray`1 packageSources, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.AddImport.AbstractAddImportFeatureService`1.GetUniqueFixesAsync(Document document, TextSpan span, ImmutableArray`1 diagnosticIds, ISymbolSearchService symbolSearchService, AddImportOptions options, ImmutableArray`1 packageSources, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteMissingImportDiscoveryService.<>c__DisplayClass4_0.<<GetUniqueFixesAsync>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)

@sharwell sharwell changed the title I'm getting lots of Roslyn Errors NullReferenceException in MethodSymbol.get_ParameterCount() Apr 15, 2024
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 22, 2024
@jaredpar jaredpar self-assigned this Apr 22, 2024
@jaredpar jaredpar added this to the 17.11 milestone Apr 22, 2024
@jaredpar
Copy link
Member

The stack doesn't have sufficient information for us to track down this crash. It seems likely that _methodSymbol is null but can't be certain. Think the next step here is to enable nullable checking in this file, add some asserts and see where that leads us.

jaredpar added a commit to jaredpar/roslyn that referenced this issue Apr 29, 2024
This is in response to dotnet#73022 where there is a null reference exception
during binder. The cause is, very likely, a `null` symbol being passed
into the binder. It's not possible to fully root cause this at the
moment but adding asserts and NRT annotations to help us track it down
in the future.
@cston
Copy link
Member

cston commented May 1, 2024

From the stack, this looks similar to #71400 and #72862.

Could the NullReferenceException be the result of re-entrancy calculating MethodSymbol.Parameters, in this case when binding a type from a lambda parameter perhaps?

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

No branches or pull requests

4 participants