The ‘uint3korr’ function inside of the mysqld server extracts a 3 byte unsigned integer from a memory buffer. One use is for ‘mediumint’ columns which encode their value in 3 bytes. MySQL 5.6 and MariaDB 10.0 claims to have optimized this function for x86 and x86_64 processors. There is a big comment that says:
Attention: Please, note, uint3korr reads 4 bytes (not 3)! It means, that you have to provide enough allocated space.
The ‘uint3korr’ optimization may be fast, but it is not valgrind safe. Here is an example where valgrind detects TokuDB reading beyond the end of a buffer when it uses the ‘uint3korr’ function.
==3899== Thread 36: ==3899== Invalid read of size 4 ==3899== at 0xB76C089: tokudb_uint3korr(unsigned char const*) (hatoku_defines.h:533) ==3899== by 0xB795C5E:[Read more...]