Search code examples
cvalgrind

Valgrind memcheck finds lots of conditional jumps and invalid reads in commercial library


I am debugging a program which links against a commercial API library (under Linux). I am using valgrind memcheck, because I am experiencing strange behavior which could be due to writes beyond allocated blocks of memory:

valgrind --tool=memcheck --error-limit=no --log-file=memcheck.log ./executable

The first thing which jumps to my eye, however, are many errors of the types

Use of uninitialised value of size (4/8/16)

Invalid read of size (4/8/16)

Conditional jump or move depends on uninitialised value(s)

Some, but not all, of these occur in __intel_sse2_strcpy or __intel_sse2_strlen. Furthermore, according to valgrind there are definite memory leaks. which appear in the library. They also appear when I compile one of the examples that ship with the library, so they are not my programming errors. Furthermore, they consistently occur with different versions of the library. Since the library is closed-source I cannot seem to clarify if the errors are fatal or not.

Practically this makes it hard for me to identify my potential own errors. I am a bit surprised to see so many warnings because I tend to fix my own programs until memcheck does not print these anymore (before I give it away at least). The question is: Can I consider such errors as save to ignore, do they commonly appear in packaged software, or are they likely even false positives (for instance because the library was compiled with optimizations)?


Solution

  • I would say:

    1. No, you can't consider them safe to ignore. Valgrind is good.
    2. Yes, they can be pretty common if the original developers have never used Valgrind or a similar tool on their code, it's reasonable to expect some hits.
    3. I don't think they are false posivives, such are rare.