garnet icon indicating copy to clipboard operation
garnet copied to clipboard

Debug.Asserts don't detect protocol violations reliably

Open TimLovellSmith opened this issue 2 years ago • 1 comments

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;
            }

TimLovellSmith avatar Mar 29 '24 23:03 TimLovellSmith

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.

badrishc avatar Mar 30 '24 05:03 badrishc