Skip to content

Misaligned read in 9.0.300 causes a razor generator crash #11863

@333fred

Description

@333fred

In Azure Pipelines using ubuntu-latest image and 9.0.300 SDK all our builds failed due to

CSC error CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentOutOfRangeException' with message 'Specified argument was out of the range of valid values.'. [/home/vsts/work/1/s/src/***.Web/***.Web.csproj]

Messages
    Microsoft (R) Visual C# Compiler version 4.14.0-3.25218.8 (d7bde97e)
    Copyright (C) Microsoft Corporation. All rights reserved.
    System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    at Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.Reader.Read(Char[] buffer, Int32 index, Int32 count)
    at System.IO.TextReader.ReadBlock(Char[] buffer, Int32 index, Int32 count)
    at Microsoft.CodeAnalysis.Text.LargeText.ReadChunksFromTextReader(TextReader reader, Int32 maxCharRemainingGuess, Boolean throwIfBinaryDetected)
    at Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.GetText()
    at Microsoft.AspNetCore.Razor.Language.CodeGeneration.DefaultDocumentWriter.WriteDocument(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
    at Microsoft.AspNetCore.Razor.Language.DefaultRazorCSharpLoweringPhase.ExecuteCore(RazorCodeDocument codeDocument, CancellationToken cancellationToken)
    at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument, CancellationToken cancellationToken)
    at Microsoft.NET.Sdk.Razor.SourceGenerators.SourceGeneratorProjectEngine.ExecutePhases(ReadOnlySpan`1 phases, RazorCodeDocument codeDocument)
    at Microsoft.NET.Sdk.Razor.SourceGenerators.SourceGeneratorProjectEngine.ProcessRemaining(SourceGeneratorRazorCodeDocument sgDocument)
    at Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator.<>c__DisplayClass6_2.<Initialize>b__26(ValueTuple`3 pair, CancellationToken _)
    at Microsoft.CodeAnalysis.TransformNode`2.<>c__DisplayClass6_0.<.ctor>b__0(TInput i, CancellationToken token)
    at Microsoft.CodeAnalysis.TransformNode`2.UpdateStateTable(Builder builder, NodeStateTable`1 previousTable, CancellationToken cancellationToken)
    -----

Setting fixed SDK version to 9.0.204 in Azure Pipeline fix issue with builds.

I can provide binlog on request (privately)

Originally posted by @alfeg in #9885

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions