When debugging the following console program:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DoIt(false));
Console.WriteLine(DoIt(true));
}
private static Boolean DoIt(Boolean abort)
{
try {
throw new InvalidOperationException();
} catch(Exception ex) {
if (abort) {
return true;
}
Console.WriteLine("Got here");
return false;
}
}
}
Why does the IDE land on the second return statement during the second call to DoIt()? The results of the execution is correct but the debugging experience is misleading.
Is this a known issue?
Is the behavior in VS 2010 the same?
It’s a flaw in the 64-bit version of the JIT compiler. It looks like it doesn’t generate entirely correct machine code address-to-statement debug mapping data. It is only somewhat accurate, the “return true” statement does actually jump to the return statement at the end of the method. But it should have hit the closing brace, not the “return false” statement.
This bug is not present in the x86 version of the JIT compiler. You typically want to use that jitter during debugging, it supports Edit+Continue. Project + Properties, Build tab, Platform Target = x86. That is automatic in VS2010 for new projects.
You can report the bug at connect.microsoft.com