title: I've found a bug in the JIT/CLR - now how do I debug or reproduce it?
body: <p>I have a computationally-expensive multi-threaded C# app that seems to crash consistently after 30-90 minutes of running.  The error it gives is</p>
  <blockquote>
  <p>The runtime has encountered a fatal error. The address of the error was at 0xec37ebae, on thread 0xbcc. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.</p>
  </blockquote>
  <p><em>(0xc0000005 is the error-code for <a href="http://blogs.msdn.com/b/calvin_hsia/archive/2004/06/30/170344.aspx" rel="noreferrer">Access Violation</a>)</em></p>
  <p>My app does not invoke any native code, or use any unsafe blocks, or even any non-CLS compliant types like <code>uint</code>.  In fact, the line of code that the debugger says caused the crash is</p>
  <pre><code>overallLength += distanceTravelled;
  </code></pre>
  <p>Where both values are of type <code>double</code></p>
  <hr />
  <p>Given all this, I believe the crash must be due to a bug in the compiler or CLR or JIT.  I'd like to figure out what causes it, or at the very least write a smaller reproduction to send into Microsoft, but I have no idea where to even begin.  I've never had to view the CIL-binary, or the compiled JIT output, or the native stacktrace <em>(there is no managed stacktrace at the time of the crash)</em>, so I'm not sure how.  I can't even figure out how to view the state of all the variables at the time of the crash <em>(VS unfortunately won't tell me like it does after managed-exceptions, and outputting them to console/a file would slow down the app 1000-fold, which is obviously not an option)</em>.</p>
  <p>So, <strong>how do I go about debugging this?</strong></p>
  <hr />
  <p><strong>[Edit]</strong> Compiled under VS 2010 SP1, running latest version of .Net 4.0 Client Profile.  Apparently it's <em>&quot;.Net 4.0C/.Net 4.0E, .Net CLR 1.1.4322&quot;</em></p>