Valgrind issues on x86_64

Hello list,

I’m currently running my app through valgrind and noticed it throws a
lot of errors in the SDL library. Consider this minimal snippet:

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <SDL.h>

int main(int argc, char **argv) {
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
fprintf(stderr, “Couldn’t initialize SDL: %s\n”, SDL_GetError());
return 1;
}
SDL_Quit();
return 0;
}

which gives me, when run through valgrind a LOT of:

==23138== Invalid read of size 8
==23138== at 0x4013DEE: (within /lib64/ld-2.6.1.so)
==23138== by 0x4009C75: (within /lib64/ld-2.6.1.so)
==23138== by 0x4005DA5: (within /lib64/ld-2.6.1.so)
==23138== by 0x4007ACF: (within /lib64/ld-2.6.1.so)
==23138== by 0x4010907: (within /lib64/ld-2.6.1.so)
==23138== by 0x400C915: (within /lib64/ld-2.6.1.so)
==23138== by 0x4010346: (within /lib64/ld-2.6.1.so)
==23138== by 0x53E6FB9: (within /lib64/libdl-2.6.1.so)
==23138== by 0x400C915: (within /lib64/ld-2.6.1.so)
==23138== by 0x53E733C: (within /lib64/libdl-2.6.1.so)
==23138== by 0x53E6F31: dlopen (in /lib64/libdl-2.6.1.so)
==23138== by 0x407283A: SDL_LoadObject (in
/usr/lib64/libSDL-1.2.so.0.11.0)
==23138== Address 0x58069B0 is 24 bytes inside a block of size 25 alloc’d
==23138== at 0x4C20EEB: malloc (in
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==23138== by 0x4007FC5: (within /lib64/ld-2.6.1.so)
==23138== by 0x4010907: (within /lib64/ld-2.6.1.so)
==23138== by 0x400C915: (within /lib64/ld-2.6.1.so)
==23138== by 0x4010346: (within /lib64/ld-2.6.1.so)
==23138== by 0x53E6FB9: (within /lib64/libdl-2.6.1.so)
==23138== by 0x400C915: (within /lib64/ld-2.6.1.so)
==23138== by 0x53E733C: (within /lib64/libdl-2.6.1.so)
==23138== by 0x53E6F31: dlopen (in /lib64/libdl-2.6.1.so)
==23138== by 0x407283A: SDL_LoadObject (in
/usr/lib64/libSDL-1.2.so.0.11.0)
==23138== by 0x40757FE: (within /usr/lib64/libSDL-1.2.so.0.11.0)
==23138== by 0x407DC85: (within /usr/lib64/libSDL-1.2.so.0.11.0)

later on…

==23138== ERROR SUMMARY: 147 errors from 4 contexts (suppressed: 174 from 1)
==23138== definitely lost: 10 bytes in 2 blocks.

Are those due to optimization or are they serious problems?

Greetings,
Johannes

Are those due to optimization or are they serious problems?

Long standing issue in glibc’s dlopen(). My guess is that it’s either
some magic that’s harmless but confuses Valgrind, or it’s some magic
that, being harmless, the glibc developers refuse to clean up.

Either way, not an SDL bug. I usually just fill in new Valgrind
suppressions for dlopen() every time glibc gets upgraded.

–ryan.