Skip to content

RoutePatternAnalyzer causes stack overflow on C# file with a lot of string operations #48097

Closed
@timmydo

Description

@timmydo

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

A file with a lot of string + operations (generated code) causes a stack overflow in the route pattern analyzer.

Analyze(context, child.AsNode()!, wellKnownTypes, routeUsageCache, cancellationToken);

Expected Behavior

clean compile

Steps To Reproduce

git clone https://github.com/timmydo/dotnet8p3analyzer1.git
cd dotnet8p3analyzer1
dotnet build

Exceptions (if any)

$ dotnet build
MSBuild version 17.6.0-preview-23174-01+e7de13307 for .NET
  Determining projects to restore...
  Restored D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj (in 83 ms).
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [D:\tmp\t2\dotnet8p3analy
zer1\dotnet8p3.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Roslyn\Microsoft.CSharp.Core.targets(80,5): error : Stack overflow. [D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Roslyn\Microsoft.CSharp.Core.targets(80,5): error : Repeat 1425 times: [D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Roslyn\Microsoft.CSharp.Core.targets(80,5): error : -------------------------------- [D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Roslyn\Microsoft.CSharp.Core.targets(80,5): error :    at Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternAnalyzer.Analyze(Microsoft.CodeAnalysis.Diagnostics.SemanticModelAnalysisContext, Microsoft.C
odeAnalysis.SyntaxNode, Microsoft.AspNetCore.App.Analyzers.Infrastructure.WellKnownTypes, Microsoft.AspNetCore.App.Analyzers.Infrastructure.RouteUsageCache, System.Threading.CancellationToken) [D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Roslyn\Microsoft.CSharp.Core.targets(80,5): error : -------------------------------- [D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Roslyn\Microsoft.CSharp.Core.targets(80,5): error :    at Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternAnalyzer.AnalyzeSemanticModel(Microsoft.CodeAnalysis.Diagnostics.SemanticModelAnalysisContext
) [D:\tmp\t2\dotnet8p3analyzer1\dotnet8p3.csproj]

.NET Version

8.0.100-preview.3.23178.7

Anything else?

No response

Metadata

Metadata

Assignees

Labels

analyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions