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

StackOverflowException when compiling project with large (12MB) cs file and targeting net6.0 #64225

Closed
omellet opened this issue Sep 22, 2022 · 7 comments · Fixed by #64322
Closed
Assignees
Milestone

Comments

@omellet
Copy link

omellet commented Sep 22, 2022

Version Used: 4.3.0-3.22423.10 (b35bb0b)

Steps to Reproduce:

  1. Build project and use TargetFramework net6.0

(A sharplab repro is ideal for compiler/language issues whenever possible)

Expected Behavior:
Builds in a couple seconds

Actual Behavior:
Crashes with StackOverflowException:

Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax.CreateRed(Microsoft.CodeAnalysis.SyntaxNode parent, int position) Line 3537	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxNode.GetRedAtZero<Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax>(ref Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax field) Line 196	C#
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.BinaryExpressionSyntax.GetNodeSlot(int index) Line 1688	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.ChildSyntaxList.ItemInternal(Microsoft.CodeAnalysis.SyntaxNode node, int index) Line 126	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurseChildren|7_3(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 300	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurse|7_0(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 288	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurseChildren|7_3(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 300	C#
 	[The 2 frame(s) above this were repeated 2514 times]	
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurse|7_0(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 288	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurseChildren|7_3(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 300	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurse|7_0(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 255	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurseChildren|7_3(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 300	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes.__recurse|7_0(Microsoft.CodeAnalysis.SyntaxNode node, ref System.Collections.Generic.ValueListBuilder<(string aliasName, string symbolName)> localAliases, ref System.Collections.Generic.ValueListBuilder<string> seenNames, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> results, ref System.Collections.Generic.ValueListBuilder<Microsoft.CodeAnalysis.SyntaxNode> attributeTargets, ref Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.<>c__DisplayClass7_0 value) Line 245	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.GetMatchingNodes(Microsoft.CodeAnalysis.DotnetRuntime.Extensions.ISyntaxHelper syntaxHelper, Microsoft.CodeAnalysis.DotnetRuntime.Extensions.GlobalAliases globalAliases, Microsoft.CodeAnalysis.SyntaxTree syntaxTree, string name, System.Func<Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken, bool> predicate, System.Threading.CancellationToken cancellationToken) Line 218	C#
 	System.Text.Json.SourceGeneration.dll!Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.ForAttributeWithSimpleName.AnonymousMethod__5((Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.SyntaxTreeInfo Left, Microsoft.CodeAnalysis.DotnetRuntime.Extensions.GlobalAliases Right) tuple, System.Threading.CancellationToken c) Line 152	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.UserFunctionExtensions.WrapUserFunction.AnonymousMethod__0((System.__Canon, System.__Canon) input, System.Threading.CancellationToken token) Line 31	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.TransformNode<(Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.SyntaxTreeInfo, Microsoft.CodeAnalysis.DotnetRuntime.Extensions.GlobalAliases), (Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)>..ctor.AnonymousMethod__0((Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.SyntaxTreeInfo, Microsoft.CodeAnalysis.DotnetRuntime.Extensions.GlobalAliases) i, System.Threading.CancellationToken token) Line 24	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.TransformNode<(Microsoft.CodeAnalysis.DotnetRuntime.Extensions.SyntaxValueProviderExtensions.SyntaxTreeInfo, Microsoft.CodeAnalysis.DotnetRuntime.Extensions.GlobalAliases), (Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)>.UpdateStateTable(Microsoft.CodeAnalysis.DriverStateTable.Builder builder, Microsoft.CodeAnalysis.NodeStateTable<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)> previousTable, System.Threading.CancellationToken cancellationToken) Line 72	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.DriverStateTable.Builder.GetLatestStateTableForNode<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)>(Microsoft.CodeAnalysis.IIncrementalGeneratorNode<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)> source) Line 59	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.TransformNode<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>), (Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)>.UpdateStateTable(Microsoft.CodeAnalysis.DriverStateTable.Builder builder, Microsoft.CodeAnalysis.NodeStateTable<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)> previousTable, System.Threading.CancellationToken cancellationToken) Line 43	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.DriverStateTable.Builder.GetLatestStateTableForNode<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)>(Microsoft.CodeAnalysis.IIncrementalGeneratorNode<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>)> source) Line 59	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.CombineNode<(Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>), Microsoft.CodeAnalysis.Compilation>.UpdateStateTable(Microsoft.CodeAnalysis.DriverStateTable.Builder graphState, Microsoft.CodeAnalysis.NodeStateTable<((Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>), Microsoft.CodeAnalysis.Compilation)> previousTable, System.Threading.CancellationToken cancellationToken) Line 32	C#
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.DriverStateTable.Builder.GetLatestStateTableForNode<((Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>), Microsoft.CodeAnalysis.Compilation)>(Microsoft.CodeAnalysis.IIncrementalGeneratorNode<((Microsoft.CodeAnalysis.SyntaxTree, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxNode>), Microsoft.CodeAnalysis.Compilation)> source) Line 59	C#
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 22, 2022
@omellet
Copy link
Author

omellet commented Sep 22, 2022

Notable that I'm trying to suppress code analysis for this project to work around the crash but I still see three analyzers on the csc.exe command line. When building w/ net472 target I don't see any analyzers being used.

@CyrusNajmabadi
Copy link
Member

Can you supply the file that is causing the crash?

@omellet
Copy link
Author

omellet commented Sep 22, 2022

I can't, unfortunately. It's proprietary code. I'll try to recreate it in a test project.

@CyrusNajmabadi
Copy link
Member

@jaredpar this is my code. Should be easy to convert it to non-recursive. I can do that when I get back from vacation. Or, if this is critical, I can walk anyone through it.

@CyrusNajmabadi
Copy link
Member

@omellet no worries! The stack and explanation are likely sufficient here. Thanks for reporting this, and sorry for he hassle here!

@omellet
Copy link
Author

omellet commented Sep 22, 2022

Am I wrong to think the analyzer shouldn't be running at all if I see /skipanalyzers+ on the command line?

@CyrusNajmabadi
Copy link
Member

This isn't an analyzer. It's a source generator. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants