How the debugger lied to my face with no shame at all
Take a look at the following code:
As you can see, something pretty freaky is going on here.
We put a value in there, and then we try to get it out, we get a totally different value.
The real repro happened in a pretty complex piece of code, and because the old value was different than the value in the debugger, we were certain that we had something that was changing data behind our back. Only after we marked the memory as read only and still saw that behavior we realized that this is actually a debugger eval bug. Instead of reading the Id property as a long, it is reading it as a byte, leading to this misleading value.
Only cost me most of my hair.
Comments
Haha, that's funny! Thanks for sharing that. :D
ouch, yes things like that can cost you your sanity ⊙_ʘ
Looks to me like the debugger thinks the value is a byte because of the cast to byte* on the call to Marshal.AllowHGlobal. Is there a reason not to change that to:
Seems like that would make more sense since the Id field is a long.
The evaluator engine was changed in VS15. This gets us lambdas etc. but takes away perf and brings some bugs. There was a popular user voice ticket to add a feature to temporarily switch to the old engine but I can't find it.
Chris, Yes, that is probably the issue. We are using
byte*
here because we are also writing additional stuff, not just the header thereComment preview