The following code works fine until I upgrade to .NET 4 (x64)
namespace CrashME
{
class Program
{
private static volatile bool testCrash = false;
private static void Crash()
{
try
{
}
finally
{
HttpRuntime.Cache.Insert("xxx", testCrash);
}
}
static void Main(string[] args)
{
Crash();
// Works on .NET 3.5 , crash on .NET 4
}
}
}
Did I just uncover a runtime bug, or is there some issue with my usage?
This would appear to be a bug in the CLR – you should report it to Microsoft.
Note that the
StackOverflowExceptionoccurs as the CLR attempts to execute theCrash, not during the execution of theCrashmethod – the program in fact never enters the method. This would appear to indicate that this is some low-level failure in the CLR. (Also note that the thrown exception also has no stack trace).This exception is incredibly specific to this situation – changing any one of a number of things fixes this, for example the following code works fine:
I would recommend that you report this to Microsoft, but attempt to work around the issue by tweaking your code in the meantime.