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

Nullable annotate InMethodyBinder #73270

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Nullable annotate InMethodyBinder #73270

wants to merge 1 commit into from

Conversation

jaredpar
Copy link
Member

This is in response to #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.

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.
@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 29, 2024
@@ -181,6 +181,7 @@ public override Binder VisitMethodDeclaration(MethodDeclarationSyntax methodDecl
if (usage == NodeUsage.MethodBody)
{
method = method ?? GetMethodSymbol(methodDecl, resultBinder);
Debug.Assert(method is not null);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotnet/roslyn-compiler wanted some feedback here. The two Debug.Assert calls are seemingly very likely identifying the cause for the NRT in #73022. Pretty much every other call in this type to GetMethodSymbol handles null as a valid return value and simply avoids creating the InMethodBinder. I'm leaning towards doing the same here but at the same time I can't find a way to construct a test case that hits the null so I'm reluctant to do that.

@@ -181,6 +181,7 @@ public override Binder VisitMethodDeclaration(MethodDeclarationSyntax methodDecl
if (usage == NodeUsage.MethodBody)
{
method = method ?? GetMethodSymbol(methodDecl, resultBinder);
Debug.Assert(method is not null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug.Assert(method is not null);

It looks like the constructor already asserts that. So, I am not sure what extra value we are going to get from asserting at the call sites.

@AlekseyTs
Copy link
Contributor

@jaredpar Is there a crash dump in the original vsfeedback ticket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants