garnet
garnet copied to clipboard
Debug.Asserts don't detect protocol violations reliably
There are various checks in the fast parsing code implemented as debug asserts. I think unfortunately, if the assert is optimized away, it becomes garbage-in-garbage-out, instead of catching a protocol violation from the client.
while (*ptr != '\r')
{
Debug.Assert(*ptr >= '0' && *ptr <= '9');
number = number * 10 + *ptr++ - '0';
if (ptr >= end)
return false;
}
Yes, this is a known limitation of the current code which was optimized for performance. We are looking into adding back some of the checks in Release mode.