Search code examples
c++valgrindgnusdl-2

SDL2 linux memory leak reported by valgrind


just trying detecting some potential issues on a small SDL2 program under linux/GCC written in C++17

valgrind report a lot of noisy memory leak about vg_replace_malloc.c that are suggested to be ignored from the official documentation (link)

(Ignore the "vg_replace_malloc.c", that's an implementation detail.)

But later on on the analysis, there is a block of:

==9891== 256 bytes in 4 blocks are definitely lost in loss record 2,243 of 2,414
==9891==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==9891==    by 0x40156B3: dl_open_worker (in /usr/lib64/ld-2.30.so)
==9891==    by 0x4E60407: _dl_catch_exception (in /usr/lib64/libc-2.30.so)
==9891==    by 0x40148FD: _dl_open (in /usr/lib64/ld-2.30.so)
==9891==    by 0x4EF139B: dlopen_doit (in /usr/lib64/libdl-2.30.so)
==9891==    by 0x4E60407: _dl_catch_exception (in /usr/lib64/libc-2.30.so)
==9891==    by 0x4E604D2: _dl_catch_error (in /usr/lib64/libc-2.30.so)
==9891==    by 0x4EF1B08: _dlerror_run (in /usr/lib64/libdl-2.30.so)
==9891==    by 0x4EF1429: dlopen@@GLIBC_2.2.5 (in /usr/lib64/libdl-2.30.so)
==9891==    by 0x493CC37: ??? (in /usr/lib64/libSDL2-2.0.so.0.12.0)
==9891==    by 0x4941DC5: ??? (in /usr/lib64/libSDL2-2.0.so.0.12.0)
==9891==    by 0x494C3CC: ??? (in /usr/lib64/libSDL2-2.0.so.0.12.0)

I am wondering if it is some sort of library dependency or a false positive or is obscurely pointing at something related to my code....

Any one could give me more insight how to interpret that definitely lost bytes snippet?


Solution

  • The problem with that output was using SDL2 from package repository that are compiled without debug info.

    Therefore recompiling the SDL2 library from source, including debug info, made the valgrind reports a lot clearer and led to solve and understand the issues.