VS2015 crashing with "A new guard page..." when just editing source code
<p><strong>The Problem:</strong></p>

<p>Visual Studio 2015 keeps crashing with this error:</p>

<p><em>A new guard page for the stack cannot be created</em></p>

<p><strong>Background:</strong></p>

<p>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.</p>

<p><a href="https://stackoverflow.com/questions/11217419/windows-service-a-new-guard-page-for-the-stack-cannot-be-created">Windows service / A new guard page for the stack cannot be created</a></p>

<p><a href="https://stackoverflow.com/questions/24780196/a-new-guard-page-for-the-stack-cannot-be-created">A new guard page for the stack cannot be created</a></p>

<p>Previously, I've only seen this error when using the Code Contracts XML documentation tool <code>ccdocgen.exe</code>.  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.</p>

<p><strong>Context:</strong></p>

<p>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 <code>Ctrl+C</code> or <code>Ctrl+X</code>.  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.</p>

<p>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.  </p>

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

<p>This is the member that I believe is causing the issue:</p>

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

<p>If I drop the query syntax, it throws errors less frequently:</p>

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

<p></s></p>

<p><strong>Questions:</strong></p>

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

<hr>

<p><strong>Edit: Additional troubleshoot steps</strong></p>

<p>As suggested by this post (<a href="https://stackoverflow.com/questions/34553269/visual-studio-2015-not-working">Visual Studio 2015 Not Working</a>), I used the crash recorder to send the issue to Microsoft.</p>

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

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

<hr>

<p><strong>Edit 2: More details</strong></p>

<p>Error dialog:
<a href="https://i.stack.imgur.com/rLhob.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rLhob.png" alt="enter image description here"></a></p>

<p>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.  <code>devenv</code>, <code>PerfWatson</code>, <code>VsHub</code>, and <code>Microsoft.VsHub.Server.HttpHost</code> are all still running and have fluctuating Working Set, Handles, and Threads stats. <code>VBCSCompiler</code> and <code>MSBuild</code> are still running, but without fluctuations (which is normally the case when not running a build).</p>

<p><strong>Edit:</strong> </p>

<p>Issue occurred on both VS2015 Update 1 and after upgrading to Update 3.  </p>

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

<p><strong>Possible Fix?</strong></p>

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

<p>Will post follow-up when either:</p>

<ul>
<li>More crashes happen, or preferably</li>
<li>I get through an entire day of work without crashes</li>
</ul>