We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3855 - Memory leak in SDL_FreeSurface in default branch
Summary: Memory leak in SDL_FreeSurface in default branch
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 major
Assignee: Brandon Schaefer
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-02 00:00 UTC by Andrei Karas
Modified: 2017-10-02 17:52 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Karas 2017-10-02 00:00:10 UTC
Look like in changeset 11551:a09c3f87a12f was introduced memory leak in SDL_FreeSurface. It leaking surface->map pointer.

Part of leak report from asan from gcc 7:
Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7fe7b7825468 in __interceptor_calloc ../../../../gcc/libsanitizer/asan/asan_malloc_linux.cc:70
    #1 0x7fe7b3142507 in SDL_AllocBlitMap /mnt/src/spm/tmp/SDL2/src/video/SDL_pixels.c:966
    #2 0x7fe7b315c437 in SDL_CreateRGBSurfaceWithFormat_REAL /mnt/src/spm/tmp/SDL2/src/video/SDL_surface.c:94
    #3 0x7fe7b3c1d052 in IMG_LoadPNG_RW /mnt/src/spm/tmp/SDL2_image/IMG_png.c:553
    #4 0x7fe7b3be6829 in IMG_LoadTyped_RW /mnt/src/spm/tmp/SDL2_image/IMG.c:198

Now default branch on changeset 11553:b89649d1a7a5
Comment 1 Brandon Schaefer 2017-10-02 17:52:18 UTC
I can confirm as well testing with testdrawchessboard.

Seems to just be missing a SDL_FreeBlitMap in the FreeSurface if its allocated.

==25380== 128 bytes in 1 blocks are definitely lost in loss record 96 of 142
==25380==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25380==    by 0x4F01E5F: SDL_AllocBlitMap (SDL_pixels.c:966)
==25380==    by 0x4F0719F: SDL_CreateRGBSurfaceWithFormat_REAL (SDL_surface.c:94)
==25380==    by 0x4F0719F: SDL_CreateRGBSurface_REAL (SDL_surface.c:127)
==25380==    by 0x4F0719F: SDL_CreateRGBSurfaceFrom_REAL (SDL_surface.c:141)
==25380==    by 0x4F0B5B1: SDL_CreateWindowFramebuffer (SDL_video.c:2212)
==25380==    by 0x4F0B5B1: SDL_GetWindowSurface_REAL (SDL_video.c:2225)
==25380==    by 0x108B8F: main (testdrawchessboard.c:121)

Fixed with:
https://hg.libsdl.org/SDL/rev/3a23ca106752