Harden debug scope update logic #824
Loading…
Reference in a new issue
No description provided.
Delete branch "HardenDebugScopeUpdate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Based on bug reports like #816 it seems there are still cases where the IL and scope offsets are out of sync in weird ways. This change modifies the logic to have no potential to cause the
IndexOutOfRangeException. While I was not able to determine what combination could cause this, it's better this way.The corner case comes when there's potential problem with the first/second instruction in the method body. The change in this case will potentially make the debug scopes slightly wrong by not pointing to the previous instruction (as there's none). Without having a real repro it's hard to tell what would be a better solution, this way it won't crash and the scopes still make sense.
/cc @SteveGilham
The ubiquitous
return new InstructionOffset (i == 0 ? items [0] : items [i - 1]);seems like a reasonable precaution.Thank you!