-
Notifications
You must be signed in to change notification settings - Fork 19
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
Roslyn analyzer throws error AD0001 NullReferenceException #3305
Comments
Hmm... This error showed up in dotnet/sdk#36807 as well:
But I don't see it in the above table. Are we missing data? |
It's now in the table, probably just took a bit. |
Interesting, I was under the impression that this only affects VMR builds but apparently this is more widespread. |
Yeah. I queried Kusto and we hit this 133 times over the last 60 days just in build logs. |
Should we add |
Yeah. Done. |
Not sure what is going on but a significant chunk of the hits here seem to be false positives. Just spent 10 minutes digging through builds and can't see the error on 75% of them. |
Cross posting the analysis from the linked bug on roslyn-analyzers This is the stack of the
That almost certainly represents this line in the roslyn analyzers code: IFieldSymbol field = ((IFieldReferenceOperation)operationContext.Operation).Field;
if (field.DeclaredAccessibility == Accessibility.Private)
{
referencedPrivateFields.TryAdd(field, default);
// Error is here.
maybeUnreferencedPrivateFields.TryRemove(field, out _);
} Both values here are non-null:
That seems like a runtime bug. |
@akoeplinger, @ericstj, @ViktorHofer at least the variation I'm seeing above appears to be a runtime bug. Do we want to use this issue to track that or file a new one? |
I think a new one since the pattern observed here (single log statement with NRE) can't necessarily tie it to the single analyzer. Do you have a dump to help triage the runtime issue or is it just based on the callstack? |
The log statements are always single line (for reasons I don't understand). But if you get the matching binlog you can usually see the full stack trace if you dig down into the messages.
This is just based on call stacks. It manifests as an exception in the analyzer and by default compiler catches those and issues a warning. The compiler can be configured to fail fast when this happens by setting the following msbuild property <Features>$(Features);debug-analyzers</Features> The failures are mostly coming on the runtime pipeline builds so you'd need to be setup to catch crash dumps on process |
Another variation of the NRE looks like this
That is basically down to this block of code. That code on it's own (no inlining) is very hard to see a NRE on. Suspect that there is some amount of inlining going on here. The invocation being analyzed here is the private static ISymbol? GetOperationSymbol(IOperation operation)
=> operation switch
{
// EXECUTION SHOULD BE HERE
IInvocationOperation iOperation => iOperation.TargetMethod,
IObjectCreationOperation cOperation => cOperation.Constructor, Basically that should be an This a very puzzling one to understand. Seems like another case we'd need the @333fred in case he can see any flaw in my analysis here. |
Agreed. Looking at that block, there shouldn't be an opportunity for a null ref there, everything is null-safe. Even inlining in that location shouldn't result in a null-ref; looking through every property called by that method, directly or indirectly, they're auto-props, and the instances they're called on are checked for null beforehand. The only thing in that closure that isn't an extremely simple auto-prop is the call to |
Note: the results from the aspnetcore-quarantined-pr pipeline aren't actionable. They don't upload any binlogs when the build fails so we can't see what is happening. @captainsafia who on aspnetcore owns this pipeline? |
AFAIK, the build isn't configured to produce binlogs at the moment (ref). @wtgodbe can help with making a change here to produce binlogs for further investigation. |
Started compiling all of the results from looking at the failures into this gist |
Note: the aspnetcore-ci pipeline uploads logs but it overwrites them on retry. That means if we hit any of these failures, then retry the logs of the failure are effectively deleted. That means we can't really get any info from any of the aspnetcore pipelines here. |
Have a gist where I've summarized the diff errors I'm seeing. Dug into five of them.
There are 2-3 other analyzer that are producing AD0001 diagnostics that I haven't bothered to dig into. I think the next steps are to get the owners of dotnet-unified-build and sdk-unified-build to enable compiler crash on analyzer exception and collection of dump logs so we can get a better idea what is going on here. |
Can we please resolve this as a dupe of dotnet/runtime#104123? That is what the runtime team's investigation lead them to. The fix is in PR and will be back ported to 9.0 P7 |
the issue just got reopened, I also think we should keep this open for a bit so we have Build Analysis tracking |
I am also running into this (and some variants) when building the .NET 9 Preview 7 using the VMR on a number of arm64 platforms using Like I mentioned in dotnet/source-build#4555 I am seeing a number of variants of errors:
|
This as a dupe of dotnet/runtime#104123. I don't have permissions to resolve the issue. |
dotnet/source-build#4576 - I suspect that SB just encountered this error in one of our 9.0 builds |
Build
https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=733128
Build leg reported
VMR Vertical Build / Ubuntu2404_DevVersions_x64 / Build
Pull Request
dotnet/sdk#42019
Known issue core information
Fill out the known issue JSON section by following the step by step documentation on how to create a known issue
@dotnet/dnceng
Release Note Category
Release Note Description
Additional information about the issue reported
No response
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=733128
Error message validated:
[error AD0001: Analyzer.*threw an exception of type 'System.NullReferenceException'
]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 7/8/2024 7:22:28 PM UTC
Report
Summary
The text was updated successfully, but these errors were encountered: