I have a serious memory leak in my program. I am trying to debug it with valgrind, but I cannot make it display lines of code for some specific leaks. There was a few leaks before that I fixed because I could see the lines of code. But the ones below cannot be seen. I suspect that the error is located in one of the libraries that my program is using, this is why I could not see the code. I tried to compile with the -static flag, but it cannot find the open gl library if I do so. Here is valgrind's output:
==11292==
==11292== HEAP SUMMARY:
==11292== in use at exit: 308,693 bytes in 3,297 blocks
==11292== total heap usage: 149,643 allocs, 146,346 frees, 2,715,768,682 bytes allocated
==11292==
==11292== 112 (56 direct, 56 indirect) bytes in 1 blocks are definitely lost in loss record 2,196 of 2,235
==11292== at 0x48455EF: calloc (vg_replace_malloc.c:1328)
==11292== by 0x6D90C8F: ???
==11292== by 0x68CAD5B: ???
==11292== by 0x68B3C50: ???
==11292== by 0x68B3E14: ???
==11292== by 0x6868769: ???
==11292== by 0x686B464: ???
==11292== by 0x6866138: ???
==11292== by 0x68162BF: ???
==11292== by 0x68535BB: ???
==11292== by 0x684FE87: ???
==11292== by 0x67E7C36: ???
==11292==
==11292== 5,323 bytes in 255 blocks are definitely lost in loss record 2,229 of 2,235
==11292== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==11292== by 0x49F4969: strdup (strdup.c:42)
==11292== by 0x57BE7BE: ???
==11292== by 0x57BE574: ???
==11292== by 0x572C486: ???
==11292== by 0x572CD56: ???
==11292== by 0x56BB098: ???
==11292== by 0x56BC377: ???
==11292== by 0x198508: makeContextCurrentGLX (in /mnt/data/git/glymmer/demo)
==11292== by 0x18F277: glfwMakeContextCurrent (in /mnt/data/git/glymmer/demo)
==11292== by 0x18F5E2: _glfwRefreshContextAttribs (in /mnt/data/git/glymmer/demo)
==11292== by 0x1A5025: _glfwCreateWindowX11 (in /mnt/data/git/glymmer/demo)
==11292==
==11292== LEAK SUMMARY:
==11292== definitely lost: 5,379 bytes in 256 blocks
==11292== indirectly lost: 56 bytes in 1 blocks
==11292== possibly lost: 0 bytes in 0 blocks
==11292== still reachable: 303,258 bytes in 3,040 blocks
==11292== suppressed: 0 bytes in 0 blocks
==11292== Reachable blocks (those to which a pointer was found) are not shown.
==11292== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==11292==
==11292== For lists of detected and suppressed errors, rerun with: -s
==11292== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
I tried to comment 1 piece of code at a time, and could not found the bug. I checked one of the basic examples in the Raylib library, and I get exactly the same leak. Same amount of bytes. So I guess Raylib is the problem. Here is the result while running the example:
==6698==
==6698== HEAP SUMMARY:
==6698== in use at exit: 308,693 bytes in 3,297 blocks
==6698== total heap usage: 99,115 allocs, 95,818 frees, 83,155,120 bytes allocated
==6698==
==6698== 112 (56 direct, 56 indirect) bytes in 1 blocks are definitely lost in loss record 2,196 of 2,235
==6698== at 0x48455EF: calloc (vg_replace_malloc.c:1328)
==6698== by 0x6D90CB3: ???
==6698== by 0x68CAD5B: ???
==6698== by 0x68B3C50: ???
==6698== by 0x68B3E14: ???
==6698== by 0x6868769: ???
==6698== by 0x686B464: ???
==6698== by 0x6866138: ???
==6698== by 0x68162BF: ???
==6698== by 0x68535BB: ???
==6698== by 0x684FE87: ???
==6698== by 0x67E7C36: ???
==6698==
==6698== 5,323 bytes in 255 blocks are definitely lost in loss record 2,229 of 2,235
==6698== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==6698== by 0x49F4969: strdup (strdup.c:42)
==6698== by 0x57BE7BE: ???
==6698== by 0x57BE574: ???
==6698== by 0x572C486: ???
==6698== by 0x572CD56: ???
==6698== by 0x56BB098: ???
==6698== by 0x56BC377: ???
==6698== by 0x192D10: makeContextCurrentGLX (in /mnt/data/git/raylib/examples/core/core_basic_window)
==6698== by 0x189A7F: glfwMakeContextCurrent (in /mnt/data/git/raylib/examples/core/core_basic_window)
==6698== by 0x189DEA: _glfwRefreshContextAttribs (in /mnt/data/git/raylib/examples/core/core_basic_window)
==6698== by 0x19F82D: _glfwCreateWindowX11 (in /mnt/data/git/raylib/examples/core/core_basic_window)
==6698==
==6698== LEAK SUMMARY:
==6698== definitely lost: 5,379 bytes in 256 blocks
==6698== indirectly lost: 56 bytes in 1 blocks
==6698== possibly lost: 0 bytes in 0 blocks
==6698== still reachable: 303,258 bytes in 3,040 blocks
==6698== suppressed: 0 bytes in 0 blocks
==6698== Reachable blocks (those to which a pointer was found) are not shown.
==6698== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==6698==
==6698== For lists of detected and suppressed errors, rerun with: -s
==6698== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
So I guess there is no solution to this problem. I would need to debug Raylib myself. It's not going to happen.
Yes, it's I think the first example that just opens a window. I think it is called "core_basic_window"
I could post an issue, I currently don't have a github account. I could build an account or find an alternate contact method.
The library is not in the Debian repository. Which is very unfortunate as it makes compiling on the gitlab CI runner complicated. I either have to download and build the entire raylib library each time I push code (consumuming more runner time than necessary). Or I need to have my own raylib gitlab project that pushes the artifacts on my server, to use the .so or .a later by my game projecta. I have not setup my CI process yet due to those complications.
I am migrating from allegro where I did not have this issue as allegro 4 is in the repositories. The only issue I had was not to be able to cross compile in windows (since again, there was no package for that).