Skip to content

Roslyn crashes with NRE when building clr+libs locally #56795

@janvorli

Description

@janvorli

I have started to hit a NRE in the Roslyn stuff after updating to the latest main and trying to build clr+libs. The issue reproduces for me quite reliably. I suspect is has started after the SDK that runtime repo uses was updated to preview 6. The call stack at the exception is

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax.get_Parameters() in Microsoft.CodeAnalysis.CSharp.dll:token 0x6003cee+0x0
   at Microsoft.CodeAnalysis.CSharp.CSharpDeclarationComputer.GetParameterListInitializersAndAttributes(BaseParameterListSyntax parameterList) in Microsoft.CodeAnalysis.CSharp.dll:token 0x6002fd4+0x0
   at Microsoft.CodeAnalysis.CSharp.CSharpDeclarationComputer.ComputeDeclarations(SemanticModel model, ISymbol associatedSymbol, SyntaxNode node, Func`3 shouldSkip, Boolean getSymbol, ArrayBuilder`1 builder, Nullable`1 levelsToCompute, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.CSharp.dll:token 0x6002fd2+0x0
   at Microsoft.CodeAnalysis.CSharp.CSharpDeclarationComputer.ComputeDeclarationsInNode(SemanticModel model, ISymbol associatedSymbol, SyntaxNode node, Boolean getSymbol, ArrayBuilder`1 builder, CancellationToken cancellationToken, Nullable`1 levelsToCompute) in Microsoft.CodeAnalysis.CSharp.dll:token 0x6002fcf+0x1c
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.ComputeDeclarationAnalysisData(ISymbol symbol, SyntaxReference declaration, SemanticModel semanticModel, AnalysisScope analysisScope, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x6002229+0x0
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.<>c__DisplayClass12_0.<TryExecuteDeclaringReferenceActions>b__0() in Microsoft.CodeAnalysis.dll:token 0x6003baa+0x0
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.CompilationData.GetOrComputeDeclarationAnalysisData(SyntaxReference declaration, Func`1 computeDeclarationAnalysisData, Boolean cacheAnalysisData) in Microsoft.CodeAnalysis.dll:token 0x6003b33+0x84
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.TryExecuteDeclaringReferenceActions(SyntaxReference decl, Int32 declarationIndex, SymbolDeclaredCompilationEvent symbolEvent, AnalysisScope analysisScope, AnalysisState analysisState, GroupedAnalyzerActions coreActions, GroupedAnalyzerActions additionalPerSymbolActions, Boolean shouldExecuteSyntaxNodeActions, Boolean shouldExecuteOperationActions, Boolean shouldExecuteCodeBlockActions, Boolean shouldExecuteOperationBlockActions, Boolean isInGeneratedCode, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x600222b+0x0
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.TryExecuteDeclaringReferenceActions(SymbolDeclaredCompilationEvent symbolEvent, AnalysisScope analysisScope, AnalysisState analysisState, Boolean isGeneratedCodeSymbol, IGroupedAnalyzerActions additionalPerSymbolActions, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x6002227+0x0
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.TryProcessSymbolDeclaredAsync(SymbolDeclaredCompilationEvent symbolEvent, AnalysisScope analysisScope, AnalysisState analysisState, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x60021f5+0x22d
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.TryProcessEventCoreAsync(CompilationEvent compilationEvent, AnalysisScope analysisScope, AnalysisState analysisState, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x60021f4+0x1bf
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessEventAsync(CompilationEvent e, AnalysisScope analysisScope, AnalysisState analysisState, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x60021f2+0x172
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessCompilationEventsCoreAsync(AnalysisScope analysisScope, AnalysisState analysisState, Boolean prePopulatedEventQueue, CancellationToken cancellationToken) in Microsoft.CodeAnalysis.dll:token 0x60021f1+0x19c

I was able to catch it with WinDbg and so far it seems like it may be a JIT issue. The failure location looks like this:

0000006f is a safepoint: 
0000006e +rbp(interior)
00007ffe`a674aeff 488bfd          mov     rdi,rbp
00007ffe`a674af02 488d742438      lea     rsi,[rsp+38h]
>>> 00007ffe`a674af07 48a5            movs    qword ptr [rdi],qword ptr [rsi]

The RDI is 0 here. As you can see, the RDI is loaded from RBP. The RBP is set at the beginning of the function to store RDX (the 2nd argument register) and never modified. And looking at the call site, I can see this:

00007ffe`a6e40092 33d2            xor     edx,edx
00007ffe`a6e40094 ff15f6e356f9    call    qword ptr [00007ffe`a03ae490] (Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax.get_Parameters(), mdToken: 0000000006003CEE)

So the JIT explicitly passes in NULL.

Both the caller and the crashing callee are optimized tier 1 code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions