Valgrind* memcheck Gives Uninitialized Value False Positives on String Routines

 

Problem : When using valgrind* to do memory checking of an executable built with the Intel® C++ Compiler 11.0 or later, you may get false positive messages on string routines that look like the following:
 
==14292== Conditional jump or move depends on uninitialised value(s)
==14292==    at 0x3D0F41442D: strlen (in /lib64/ld-2.5.so)

or
 
==14292== Conditional jump or move depends on uninitialised value(s)
==14292==    at 0x3D0F40A2E5: _dl_relocate_object (in /lib64/ld-2.5.so)


An example of a code that would get false positives is as follows:
 
#include <cstring>
#include <iostream>

int main() {
   std::cout << "The result of strcmp of two identical strings is " << std::strcmp("String A", "String A") << std::endl;
   return(0);
}


Environment : Windows*, Linux* or Mac OS* on IA-32 or Intel® 64-based systems


Root Cause : This is a known issue with valgrind which they have documented on their documentation page under Known Limitations†.  Valgrind gives false positives on the highly optimized string routines the Intel® C++ Compiler provides for systems that support Intel® Streaming SIMD Extensions 2 (this environment is targeted by default with the 11.x and later compilers).


Resolution : Valgrind 3.10 appears to resolve the issue according to testing, so it's recommended to upgrade to that version or later.

Alternative solutions include:

  • Building your application with /arch:IA32 (Windows*) or -mia32 (Linux*/Mac OS*).  This will likely affect performance.
  • Use Intel® Inspector XE which does not have this issue.
† This link will take you off the Intel website.  Intel is not responsible for its content.
 

 

For more complete information about compiler optimizations, see our Optimization Notice.