tigr icon indicating copy to clipboard operation
tigr copied to clipboard

Mesa Memory Leak

Open AdreKiseque opened this issue 8 months ago • 3 comments

TIGR seems to cause memory leaks whenever it... runs. Clang Static Analyzer and htop return no issue, but Clang LeakSanitizer and Valgrind both freak out. LeakSanitizer output:

tigr-test/leak/ $ ./leak
==109252==WARNING: invalid path to external symbolizer!
==109252==WARNING: Failed to use and restart external symbolizer!

=================================================================
==109252==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6720 byte(s) in 1 object(s) allocated from:
    #0 0x55ff8ecea592  (/workspaces/160550426/tigr-test/leak/leak+0x33592) (BuildId: b4db616332db8de29c4f8cac38b13bff386a95bb)
    #1 0x7d08ceabe7b3  (/lib/x86_64-linux-gnu/libGLX_mesa.so.0+0x317b3) (BuildId: 81f27aa4cfe213187c5a2dda6902a87fd132a76e)

SUMMARY: LeakSanitizer: 6720 byte(s) leaked in 1 allocation(s).

Valgrind's outputs are massive since it seems to print for each loop of the window, but it points in the same direction. Some sample lines: Edit: It is not printing out errors for every loop, it just prints one massive block of errors on exit.

==96672== 194,880 bytes in 840 blocks are still reachable in loss record 2,689 of 2,692
==96672==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==96672==    by 0x5586802: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==96672==    by 0x558A0F7: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==96672==    by 0x50DC79A: glXChooseFBConfig (in /usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0)
==96672==    by 0x4AA7D8F: (below main) (libc_start_call_main.h:58)
==96672== 
==96672== 265,072 bytes in 1 blocks are indirectly lost in loss record 2,690 of 2,692
==96672==    at 0x484DE30: memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==96672==    by 0x484DF92: posix_memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==96672==    by 0x58428B9: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==96672==    by 0x5790660: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==96672==    by 0x5587C28: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==96672==    by 0x5586F28: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)

I'm running on Codespaces. I can't tell if the issue is with TIGR's useage of Mesa or Mesa itself, nor can I tell if this is an actual problematic leak or a false positive, but it seems worth calling attention to. Happens with any useage of TIGR, down to drawing an empty window.

#include "../tigr/tigr.h"

int main(int argc, char *argv[])
{
    Tigr *screen = tigrWindow(320, 240, "Hello", 0);
    while (!tigrClosed(screen))
    {
        tigrUpdate(screen);
    }
    tigrFree(screen);
    return 0;
}

Hopefully this helps track something down.

AdreKiseque avatar May 31 '24 01:05 AdreKiseque