VS2015 crashing with “A new guard page…” when just editing source code

瘦欲@ 提交于 2021-02-10 05:33:50

问题


The Problem:

Visual Studio 2015 keeps crashing with this error:

A new guard page for the stack cannot be created

Background:

There are already a few questions out there regarding this error in other contexts, but they all appear to be related to interoperating with legacy COM code or designer tools in Visual Studio. I am just trying to edit a C# source file.

Windows service / A new guard page for the stack cannot be created

A new guard page for the stack cannot be created

Previously, I've only seen this error when using the Code Contracts XML documentation tool ccdocgen.exe. When I was using VS2013 with ccdocgen, the error came up occasionally when building, but it would only crash ccdocgen, not VS. After upgrading to VS2015 I've seen it very frequently when building anything that uses anonymous methods if I'm using ccdocgen, but until now it was still only crashing ccdocgen and not VS. Also worth pointing out is that the error dialog looks slightly different when the error is thrown on build by ccdocgen.

Context:

The solution I'm currently working on uses Code Contracts for pre-conditions and post-conditions, but does not utilize the static checker at all. I am getting this error while editing code, just doing simple things like typing, selecting text, using Ctrl+C or Ctrl+X. Since that's started, I've disabled all of the Code Contracts tools on the project I'm currently working on (but not in the entire solution), but the error is still coming up sporadically.

Based on answers to other questions regarding this error message, it is caused by a stack overflow somewhere. Since this error is happening when just editing text, and I've only run into it since I've moved to VS2015, my assumption is that it is related to some background parsing that Roslyn is doing.

Some Code: Edit: I got the error with both versions of this property commented out, so that's not it.

This is the member that I believe is causing the issue:

public DataView JoinedRecords =>
    (from r1 in Table1.AsEnumerable()
    join r2 in Table2.AsEnumerable()
           on r1.Field<int>("ID") equals r2.Field<int>("ID")
    where r2.Field<bool>("IsPending")
    select r1)
    .CopyToDataTable().AsDataView();

If I drop the query syntax, it throws errors less frequently:

public DataView JoinedRecords =>
    query = Table1.AsEnumerable()
        .Join(Table2.AsEnumerable(),
            r1 => r1.Field<int>("ID"),
            r2 => r2.Field<int>("ID"),
            (r1, r2) => r1)
        .CopyToDataTable().AsDataView();

Questions:

  • Has anyone else had this issue?
  • Am I right in believing this is a Roslyn issue?
  • How can I get more data on the crash? Is there a handy VS error log I can find?
  • Am I missing something?

Edit: Additional troubleshoot steps

As suggested by this post (Visual Studio 2015 Not Working), I used the crash recorder to send the issue to Microsoft.

I also ran VS with the /log argument and found 2 errors in the log, but they don't sound very relevant.

<entry>
    <record>563</record>
    <time>2016/06/29 16:00:08.841</time>
    <type>Error</type>
    <source>Extension Manager</source>
    <description>Extension will not be loaded because an extension with the same ID &apos;Microsoft.Windows.DevelopmentKit.Desktop&apos; is already loaded at C:\PROGRAM FILES (X86)\COMMON FILES\MICROSOFT\EXTENSIONMANAGER\EXTENSIONS\MICROSOFT\WINDOWS KITS\8.0\DESKTOP SDK\...</description>
    <path>C:\PROGRAM FILES (X86)\COMMON FILES\MICROSOFT\EXTENSIONMANAGER\EXTENSIONS\MICROSOFT\WINDOWS KITS\8.1\DESKTOP SDK\</path>
  </entry>
  <entry>
    <record>564</record>
    <time>2016/06/29 16:00:09.587</time>
    <type>Error</type>
    <source>Color Theme Service</source>
    <description>The color &apos;Popup&apos; in category &apos;de7b1121-99a4-4708-aedf-15f40c9b332f&apos; does not exist.     </description>
  </entry>

Edit 2: More details

Error dialog:

I also noticed, when the error dialog pops up, but before I click 'OK', many of the Visual Studio processes still look normal in the Task Manager. devenv, PerfWatson, VsHub, and Microsoft.VsHub.Server.HttpHost are all still running and have fluctuating Working Set, Handles, and Threads stats. VBCSCompiler and MSBuild are still running, but without fluctuations (which is normally the case when not running a build).

Edit:

Issue occurred on both VS2015 Update 1 and after upgrading to Update 3.

Issue has been with Code Contracts v1.9, tried uninstall and re-install of CC 1.9 to no effect.

Possible Fix?

Installed CC v1.10-RC2 and I've been working for a few minutes without VS crashing.

Will post follow-up when either:

  • More crashes happen, or preferably
  • I get through an entire day of work without crashes

回答1:


Am I right in believing this is a Roslyn issue?

I think that it's unlikely Roslyn is the direct cause of this problem. In particular because of this piece of data.

When I was using VS2013 with ccdocgen, the error came up occasionally when building, but it would only crash ccdocgen, not VS

Roslyn didn't ship until VS2015. Before that the compiler was a completely different piece of code (native vs. managed). While it's possible both compilers had the same bug here it's unlikely for this specific type of issue.

I think it's more likely an issue with Code Contracts. In particular Roslyn, and the native compiler, produce the same sequence of IL that is causing an issue with Code Contracts.

I'm going to notify the Code Contracts team about this and see what their analysis is.




回答2:


I had the same issue. I handled Recursive call. And Error is gone. So I would suggest you to add some exit point to any of the recursive function which is at the start. Or just try commenting the recursive call, To Verify this is happening just because of Stack Overflow due to recursive call.

If not recursive call, then possibly infinite loop.

Good luck !!



来源:https://stackoverflow.com/questions/38103495/vs2015-crashing-with-a-new-guard-page-when-just-editing-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!