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

Visual Studio 2022 crashes for certain solution after setting net6.0 instead of net5.0 #59190

Closed
vsfeedback opened this issue Feb 1, 2022 · 2 comments · Fixed by #59203
Closed
Assignees
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version]
I have existing solution for .NET 5 (ASP.NET Core), I worked with it in VS 2019, all works good.
Now I want upgrade all projects from this solution to .NET 6 and work in VS 2022.
I replaced net5.0 to net6.0 in all .csproj files in this solution.
And after that VS 2022 crashed.
If I launch VS 2022 again and open this solution then VS 2022 hangs and then crashes.

Problem is only for this solution.
For other similar solutions all works good - I replaced net5.0 to net6.0 and VS didn't crash.


Original Comments

Feedback Bot on 12/26/2021, 05:17 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Peng Ge [MSFT] on 12/27/2021, 00:16 AM:

Dear customer, thank you for your feedback and I am sorry to hear that you are running into this issue.
You can try to repair Visual Studio, disable third-party extensions, delete the .vs and bin folders of the project and reload the project.

Pavel Mokshin on 12/27/2021, 09:22 AM:

Hi. I tried all these ways, they didn’t help.

Peng Ge [MSFT] on 12/29/2021, 00:18 AM:

Open the project in Visual Studio 2022, then modify the target framework in the project properties->application->General, will you encounter this issue?

Pavel on 12/29/2021, 00:37 PM:

Yes.
I did it now for all projects in solution.
Problem is only for one project - when I switch it to .NET 6 then Visual Studio 2022 hangs and crashes.

Don’t know is it important or not but in this project I use Roslyn SDK.
I attached this proj file which I use in .NET 5.
If change net5.0 to net6.0 in it then I encounter this issue.
At moment of switch I have old versions of Nuget packages which I used in .NET 5.
I also tried manually change versions of Nuget packages to latest (4.0.1 for Roslyn and 6.0.1 for .NET) but it didn’t help.

Also attached screenshot with some error messages from VS.
But I couldn’t click “Show stack trace” because VS hangs.

Pavel on 12/29/2021, 04:05 PM:

Created and attached small solution with one project, it has this problem too - VS 2022 hangs and crashes.
Here is used Antlr4.
Some files with code are very big.
Maybe this is the reason of problem.

Feedback Bot on 12/30/2021, 01:06 AM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.

Pavel on 12/30/2021, 04:33 AM:

Also found similar ticket: https://developercommunity.visualstudio.com/t/visual-studio-2022-preview-crashes-opening-solutio/1519923
Here user (randyL2004) found workaround but it doesn’t work for me.

In this ticket MS Team said that it’s bug of Antlr and suggested write to them.
User created issue on Antlr github: antlr/antlr4#3274
Please look this discussion, maybe it will help.

Peng Ge [MSFT] on 1/18/2022, 01:53 AM:

Thank you for your feedback.
Will you encounter this issue without using Antlr?
We look forward to hearing from you!

Pavel Mokshin on 1/20/2022, 00:37 AM:

No, it’s only with Antlr. But Antlr is required for this project.
For now I’m forced to use Rider IDE from Jetbrains, it works good for this project.

Drew Noakes [MSFT] on 1/22/2022, 02:42 AM:

Hi @Pavel Mokshin, thanks very much for the bug report, especially for the attached project. I can reproduce the problem and have assigned this ticket to the relevant team, who will look into it for you.

Feedback Bot on 1/23/2022, 08:57 PM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 1, 2022
@AlekseyTs AlekseyTs self-assigned this Feb 1, 2022
@AlekseyTs
Copy link
Contributor

This issue was moved from https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1454807.
Here is an additional information from that work item:

The attached solution crashes VS when opened. Debugging shows it's a stack overflow:

Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax.CreateRed(Microsoft.CodeAnalysis.SyntaxNode parent, int position)	Unknown
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxNode.GetRedAtZero<Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax>(ref Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax field)	Unknown
 
Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.BinaryExpressionSyntax.GetNodeSlot(int index)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.ChildSyntaxList.ItemInternal(Microsoft.CodeAnalysis.SyntaxNode node, int index)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.ChildSyntaxList.Enumerator.Current.get()	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxWalker.Visit(Microsoft.CodeAnalysis.SyntaxNode node)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.IncrementalGeneratorSyntaxWalker.Visit(Microsoft.CodeAnalysis.SyntaxNode node)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxWalker.Visit(Microsoft.CodeAnalysis.SyntaxNode node)	Unknown
 
[The 2 frame(s) above this were repeated 2377 times]	
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxWalker.Visit(Microsoft.CodeAnalysis.SyntaxNode node)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.IncrementalGeneratorSyntaxWalker.Visit(Microsoft.CodeAnalysis.SyntaxNode node)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.IncrementalGeneratorSyntaxWalker.GetFilteredNodes(Microsoft.CodeAnalysis.SyntaxNode root, System.Func<Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken, bool> func, System.Threading.CancellationToken token)	Unknown
 
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.SyntaxInputNode<Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax>.Builder.VisitTree(System.Lazy<Microsoft.CodeAnalysis.SyntaxNode> root, Microsoft.CodeAnalysis.EntryState state, Microsoft.CodeAnalysis.SemanticModel model, System.Threading.CancellationToken cancellationToken)	Unknown
 
... 

@AlekseyTs
Copy link
Contributor

Somewhat similar stack overflow can be reproduced with the following unit-test:

        [Fact]
        public void LongBinaryExpression()
        {
            var source = @"
class C {
public static readonly string F = ""a""
";

            for (int i = 0; i < 3500 + 3500; i++)
            {
                source += @" + ""a""
";
            }


            source += @";
}
";
            var parseOptions = TestOptions.RegularPreview;
            Compilation compilation = CreateCompilation(source, options: TestOptions.DebugDll, parseOptions: parseOptions);
            compilation.VerifyDiagnostics();
            Assert.Single(compilation.SyntaxTrees);

            var generator = new PipelineCallbackGenerator(ctx =>
            {
                ctx.RegisterSourceOutput(ctx.SyntaxProvider.CreateSyntaxProvider((node, ct) => node is ClassDeclarationSyntax c, (context, ct) => context.Node).WithTrackingName("Syntax"), (context, ct) => { });
                ctx.RegisterSourceOutput(ctx.CompilationProvider, (context, ct) => { });
                ctx.RegisterSourceOutput(ctx.AnalyzerConfigOptionsProvider, (context, ct) => { });
                ctx.RegisterSourceOutput(ctx.ParseOptionsProvider, (context, ct) => { });
                ctx.RegisterSourceOutput(ctx.AdditionalTextsProvider, (context, ct) => { });
                ctx.RegisterImplementationSourceOutput(ctx.MetadataReferencesProvider, (context, ct) => { });
            });

            GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { new InMemoryAdditionalText("text.txt", "") }, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true));
            driver = driver.RunGenerators(compilation);
            driver.GetRunResult();
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
3 participants