dotnet/roslyn

StackOverflowException during VB build with too many nested If/Then/Else statements

Open

#30,741 opened on Oct 24, 2018

View on GitHub
 (2 comments) (0 reactions) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-CompilersBugDeveloper Communityhelp wanted

Description

I have a VB.net project that uses the v3.5\EdmGen.exe to generate a Model.Views.vb file. This generated file contians over 830 views.

Since the Visual Studio 2017 V15.8.1 update, trying to build the project containing the Model.Views.vb fails, just giving the following output.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\Microsoft.VisualBasic.Core.targets(41,5): error : Process is terminated due to StackOverflowException.

Worse still, this leaves Visual Studio in an unstable condition and trying to do more builds randomly locks the entire PC(Win 7 Pro machine) up requiring a power reset. This happens on multiple of our development machines.

I've managed to trace the problem down the the way the DotNet 3.5 EdmGen.exe program generates the Model.Views.vb file. It nests all the If/Then/Else statements for every new View and once the nested If statements reach approximately 824/825 levels deep, it causes the StackOverflowException.

If I manually remove the some of the nested If/Then/Else statements(and their View code), it builds OK. So there seems to be a limit on how many levels you can nest If/Then/Else statements.

I can also confirm that in VS2017 V15.7.3 we could build our current Model.Views.vb (with over 830 nested If/Then/Else statements), but since VS2017 V15.8.1 (up to 15.8.4) the same file fails with the StackOverflowException.

I am currently getting around the problem by using the v4.0.30319\EdmGen.exe which generates the Model.Views.vb WITHOUT all the nested If/Then/Else stetements.

This issue has been moved from https://developercommunity.visualstudio.com/content/problem/336992/stackoverflowexception-during-vb-build-with-too-ma.html VSTS ticketId: 685409 These are the original issue comments: (no comments) These are the original issue solutions: (no solutions)

Contributor guide