none
Visual Studio Enterprise crashes while building with code analysis

    Question

  • When I try to build my c# solution from visual studio enterprise, Visual studio is crashing. The build configuration without code analysis enabled is working fine. This issue happens only for configurations having code analysis enabled. The application log gives error as below.

    Application: devenv.exe

    Framework Version: v4.0.30319

    Description: The application requested process termination through System.Environment.FailFast(string message). Message: System.ArgumentException: Value does not fall within the expected range. at Microsoft.VisualStudio.Shell.Interop.IVsRunningDocumentTable4.GetDocumentData(UInt32 cookie) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.MiscellaneousFilesWorkspace.AttachToDocument(UInt32 docCookie, String moniker) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.MiscellaneousFilesWorkspace.Registration_WorkspaceChanged(Object sender, EventArgs e) at Microsoft.CodeAnalysis.WorkspaceRegistration.RaiseEvents() at Microsoft.CodeAnalysis.Workspace.<>c__DisplayClass199_0.<RegisterText>b__0() at Roslyn.Utilities.TaskExtensions.<>c__DisplayClass14_0.<ContinueWithAfterDelay>b__1(Task _) at Roslyn.Utilities.TaskExtensions.<>c__DisplayClass2_0.<SafeContinueWith>b__0(Task antecedent) at Roslyn.Utilities.TaskExtensions.<>c__DisplayClass6_0`1.<SafeContinueWith>b__0(Task t) Stack: at System.Environment.FailFast(System.String, System.Exception) at Microsoft.CodeAnalysis.FailFast.OnFatalException(System.Exception) at Microsoft.CodeAnalysis.ErrorReporting.FatalError.Report(System.Exception, System.Action`1<System.Exception>) at Microsoft.CodeAnalysis.ErrorReporting.FatalError.ReportUnlessCanceled(System.Exception) at Roslyn.Utilities.TaskExtensions+<>c__DisplayClass6_0`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<SafeContinueWith>b__0(System.Threading.Tasks.Task) at Microsoft.VisualStudio.Shell.Interop.IVsRunningDocumentTable4.GetDocumentData(UInt32) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.MiscellaneousFilesWorkspace.AttachToDocument(UInt32, System.String) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.MiscellaneousFilesWorkspace.Registration_WorkspaceChanged(System.Object, System.EventArgs) at Microsoft.CodeAnalysis.WorkspaceRegistration.RaiseEvents() at Microsoft.CodeAnalysis.Workspace+<>c__DisplayClass199_0.<RegisterText>b__0() at Roslyn.Utilities.TaskExtensions+<>c__DisplayClass14_0.<ContinueWithAfterDelay>b__1(System.Threading.Tasks.Task) at Roslyn.Utilities.TaskExtensions+<>c__DisplayClass2_0.<SafeContinueWith>b__0(System.Threading.Tasks.Task) at Roslyn.Utilities.TaskExtensions+<>c__DisplayClass6_0`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<SafeContinueWith>b__0(System.Threading.Tasks.Task) at System.Threading.Tasks.ContinuationResultTaskFromTask`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].InnerInvoke() at System.Threading.Tasks.Task.Execute() at System.Threading.Tasks.Task.ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) at System.Threading.Tasks.Task.ExecuteEntry(Boolean) at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

    Sample project configuration is as below.

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseCR|x64'">
        <OutputPath>..\..\..\..\BinReleaseCR(x64)\GUI\Product\</OutputPath>
        <DefineConstants>TRACE;CODE_ANALYSIS;USE_WINCODECS</DefineConstants>
        <Optimize>true</Optimize>
        <DebugType>pdbonly</DebugType>
        <PlatformTarget>x64</PlatformTarget>
        <CodeAnalysisLogFile>..\..\..\..\BinReleaseCR(x64)\GUI\CodeAnalysisLog\GUI.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
        <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
        <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
        <ErrorReport>prompt</ErrorReport>
        <CodeAnalysisRuleSet>..\..\..\..\CodingRules\AlsR_CodingRules\CodingRulesFromMicrosoftAllRules.ruleset</CodeAnalysisRuleSet>
        <CodeAnalysisRuleSetDirectories>;C:\Program Files (X86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
        <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
        <CodeAnalysisRuleDirectories>;C:\Program Files (X86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
        <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
        <DocumentationFile>..\..\..\..\BinReleaseCR(x64)\GUI\Product\GUI.XML</DocumentationFile>
        <RunCodeAnalysis>true</RunCodeAnalysis>
        <Prefer32Bit>false</Prefer32Bit>
      </PropertyGroup>

    Thursday, July 21, 2016 8:49 AM

All replies

  • You should post this question over in the Roslyn forums (https://github.com/dotnet/roslyn) as it could be an issue with Roslyn or an issue with one of the rules in the Microsoft All Rules set. You might also consider switching to a different ruleset to see if you can narrow down the issue.
    Thursday, July 21, 2016 1:57 PM
  • Hi,

    Thank you for posting here.

    Since your issue is related to VS analysis. So I will move the thread to VS General forum for better support.

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Hart


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Friday, July 22, 2016 2:28 AM
  • In my case it is not crashing while building some specific project. The solution contains many projects and it is crashing at random places. I tried building few projects by unloading other projects. By this way I can build all the projects.
    Friday, July 22, 2016 4:33 AM
  • Hi VIJIN P V,

    Like CoolDadTx's suggestion, if you change the code analyze rules option, how about the result?

    Do you test it in other VS2015 machine? Is it the latest version VS2015 with update 3?

    If there are many projects in the same solution, if possible, I suggest you create several solutions for them, check it again. Sometimes it would generate the performance issue if the solution has many projects.

    Note: You could take a backup before you create different solutions.

    One import issue is that please check that whether you got many code analyze warning messages in your side from the Error list windows.

    We could suppress or ignore them, check it again using this method:

    https://msdn.microsoft.com/en-us/library/ee1hzekz.aspx

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 22, 2016 7:48 AM
    Moderator
  • Thanks Jack for your response. Please find my answers below.

    Do you test it in other VS2015 machine? Is it the latest version VS2015 with update 3?

    Answer: We tested in two machines and we observed the same issue in both machines. Yes it is the latest VS2015 update 3.

    Your suggestion of creating multiple solution is already been checked. But not exactly by splitting. I built only selected projects(say 10-15 projects at a time) by unloading the other projects from solution. Even though I observed similar crash randomly, I could build all the projects in the solution. It is a solution containing 180 projects and yes there are many code analysis warnings(~20K). It seems to be a performance issue. One thing to note here is that the same solution was building fine in VS2010. After the VS2015 and .Net 4.6 migration, we are facing this issue. Also splitting to multiple solution would be difficult for the build managers to handle and there is no guarantee that by splitting it works as I could see the same crash while building only some loaded projects in the solution.

    I need to check by changing the coding rule set. I will let you know. But for sure this will not be a solution for the final build.

    Friday, July 22, 2016 10:14 AM
  • Forgot to mention that the build works fine using MsBuild command for all the configuration. But the same solution is not building if you are using devenv.exe(through UI or command).
    Friday, July 22, 2016 10:20 AM
  • Hi VIJIN P V,

    >>It is a solution containing 180 projects and yes there are many code analysis warnings(~20K). It seems to be a performance issue.

    >>I need to check by changing the coding rule set. I will let you know. But for sure this will not be a solution for the final build.

    How about the result if you change the rule option?

    As you said that it has so many code warnings, like my previous reply, if you suppress or ignore those warning, how about the result? At least, we could know that whether so many warning messages really impact the performance. 

    https://msdn.microsoft.com/en-us/library/ms244717.aspx

    >>But the same solution is not building if you are using devenv.exe(through UI or command).

    Not very sure that how you build your solution in command line, but as you said before the projects build normally in the VS IDE without the code analyze, I think it would be not a real reason for this issue. Maybe so many warnings really impact the VS performance.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 25, 2016 12:37 PM
    Moderator
  • Hi Jack,

    Since changing rule option in all project will impact our version control I could not check it now. Now we are blocked and could not find a way to move forward.

    We have four configurations

    1. Debug : Configuration without code analysis. This configuration builds fine.

    2. Release: Configuration without code analysis. This configuration builds fine.

    3. DebugCR : Same as that of debug configuration plus the code analysis. This configuration is not building.

    4. ReleaseCR : Same as that of Release configuration plus the code analysis. This configuration is not building.

    As I mentioned in my previous thread, DebugCR and ReleaseCR configuration itself is building if I build only few projects at a time. So it is definitely a performance issue. As you mentioned in your reply, issue could be because of so many code analysis warnings. I think it will definitely build if I decrease the rule sets, but it is not a feasible solution for now.

    By command line I mean to say If I run below command in VS command prompt, it is building fine.

    msbuild "GUI.sln" /t:Clean /p:Configuration=ReleaseCR;Platform=x64

    But the same solution and same configuration is not building If I run the below command or do a Rebuild All from IDE menu.

    "C:\Program Files (X86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" "GUI.sln" /rebuild "ReleaseCR|x64" /OUT BuildGUI-ReleaseCR-x64.log

    Tuesday, July 26, 2016 5:39 AM
  • Have you tried running VS in safemode to eliminate the possibility of some extension getting in the way (such as solution visualizer or another of the power tools)? It could also be something with the scrollbar's map mode. Basically anything that highlights warnings/errors during compilation.

    Tuesday, July 26, 2016 1:18 PM
  • Hi Jack,

    Yes I tried VS in safe mode as well. But no luck. The same crash is present in safe mode as well. This was a suggestion from some thread. But it did not work for me.

    In my IDE i did not enable map mode for scroll bars.

    Thanks & Regards,

    Vijin

    Tuesday, July 26, 2016 2:32 PM
  • Hi Vijin,

    Thanks for your friendly response.

    Since we couldn't repro this issue with a simple sample, so it is hard for us to make sure what the real reason is.

    But we would think about the real reason why you use the code analysis tool, do you will resolve those warning messages or just want to collect the warnings results?

    I often use the code analysis tool to help me improve the code habit, so I could follow the better code rules, if I get some warnings, I will try to find the real reason why I got it, and then optimize my code lines.

    Based on our previous discussion, if you use the default rules without any extension tools/libraries, and disable the rules really have no this issue, at least, we could know that this issue is related to the code analysis tool even if we don't know that whether it is related to the warnings count, size or others.

    In addition, as you said that it works well using the MSBuild, please check that whether it really enable the code analysis using it:

    http://stackoverflow.com/questions/6399014/disable-code-analysis-for-some-projects-using-msbuild

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 27, 2016 12:29 PM
    Moderator
  • Hi Jack,

    Thanks for the reply.

    In our product we need this code analysis report for auditing purpose and also we will fix the warnings gradually. So we cannot ignore or remove the rule set from the project configuration.

    In my case I could see that MSBuild command builds with the code analysis. We don't use any specific switch for this as our configuration is project specific, that is each project contains this code analysis settings.

    Thanks & Regards,

    Vijin

    Thursday, July 28, 2016 6:20 AM
  • Hi Vijin,

    If so, I also couldn't find the direct solution for this issue.

    Maybe using the MSBuild to collect the warning reports would be a better workaround for you if it is hard to create few projects in one solution or others.

    If you really want to analyze the crashed issue, one idea is that you could collect the crashed dump files, and then submit it to the connect report, the report team experts will help you analyze the dump file:

    http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 29, 2016 5:07 AM
    Moderator
  • Thanks Jack. I will try sharing the dump.

    Regards,

    Vijin

    Friday, July 29, 2016 6:30 AM
  • You are welcome, Vijin.

    If you submit a connect report, please share me the link her, so I could get the latest information from the report team directly.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, July 30, 2016 6:11 AM
    Moderator
  • Hi Jack,

    Please refer below link for the connect call.

    https://connect.microsoft.com/VisualStudio/feedback/details/2999487/visual-studio-hang-or-crash-during-build

    Thanks & Regards,

    Vijin

    Monday, August 01, 2016 10:37 AM
  • I am the Software Configuration Management build person for 20 developers.  We see the same problem with Code Analysis in the Visual Studio 2015 SP3 IDE compiling our solutions.  The solution I have been using as the test case to debug this problem has 27 projects.  Code Analysis "HANGS" randomly.  Every once in a while the build of all 27 projects will succeed with approximately 4800 Code Analysis warnings.  The other nine times out of ten the build will hang randomly with any number of warnings reported in the "Warnings" window.  Sometime is hangs as early as 4 warnings.  Other times it will hang near the end when the build is nearly finished with over 4000 warnings.  And other times it will hang anywhere in between these two extremes.  The same solution with 27 projects compiles just fine in Visual Studio 2013 on the same build machine or any developers machine.  Also Code Analysis hangs with VS2015 SP3 on developers desktop machines.  I have been fighting this problem for over three weeks now and it is totally consuming all of my time.  My manager is getting impatient with a solution.  HOWEVER, I am now convinced this is a BUG in Visual Studio 2015 service pack 1, 2 or 3 and/or .NET 4.6.1.  I have tried different rule sets, rebooting the build machine with clean project folder tree from source control, increasing RAM to 16 GB (task manager show plenty of RAM available now), etc., etc..  I was going to put in a Ticket to Microsoft Visual Studio support today when my manager found this support thread.  Microsoft needs to fix this bug.  It is causing a lot of grief for our development team.  Maybe we will have to go back to VS 2013 because VS2015 is unreliable !!!  Please help.  I am willing to work with VS support one on one to resolve this BUG !  I will devote the time necessary for Microsoft support to diagnose the real cause of this problem.  Email me or call me.  You have my contact info.

    Thank you,

    SCM Build guy

    Monday, August 01, 2016 10:16 PM