Valgrind

Valgrind is in essence a virtual machine using just-in-time compilation techniques, including dynamic recompilation.

Valgrind recompiles binary code to run on host and target (or simulated) CPUs of the same architecture.

As data is moved around or manipulated, the instrumentation code keeps track of the A and V bits, so they are always correct on a single-bit level.

This feature enables Memcheck to detect off-by-one errors where a program reads or writes outside an allocated block by a small amount.

The problems Memcheck can detect and warn about include the following: The price of this is lost performance.

[21][22] Several others have also made significant contributions, including Nicholas Nethercote, Bart Van Assche, Florian Krohm, Tom Hughes, Philippe Waroquiers, Mark Wielaard, Paul Floyd, Petar Jovanovic, Carl Love, Cerion Armour-Brown and Ivo Raisr.

[24] In addition to the performance penalty, an important limitation of Memcheck is its inability to detect all cases of bounds errors in the use of static or stack-allocated data.

[25] The following code will pass the Memcheck tool in Valgrind without incident, despite containing the errors described in the comments: