SDL & SDL_mixer memory leaks

Hello all,

I was wondering if anyone has run SDL apps through valgrind and what results
they got.
Here’s some info:

SDL_InitSubSystem / SDL_AudioInit leak:
==17685== 25,812 bytes in 717 blocks are possibly lost in loss record 78 of
78
==17685== at 0x400473F: calloc (vg_replace_malloc.c:279)
==17685== by 0x44246318: (within /lib/libasound.so.2.0.0)
==17685== by 0x44246440: (within /lib/libasound.so.2.0.0)
==17685== by 0x442484E8: (within /lib/libasound.so.2.0.0)
==17685== by 0x44248A1D: (within /lib/libasound.so.2.0.0)
==17685== by 0x44248CC1: (within /lib/libasound.so.2.0.0)
==17685== by 0x4424B1F1: snd_config_update_r (in /lib/libasound.so.2.0.0)
==17685== by 0x4424B977: snd_config_update (in /lib/libasound.so.2.0.0)
==17685== by 0x4426FF88: snd_pcm_open (in /lib/libasound.so.2.0.0)
==17685== by 0x4EF2BDEF: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EEF6C4F: SDL_AudioInit (in /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EEF5FEE: SDL_InitSubSystem (in
/usr/lib/libSDL-1.2.so.0.7.3)

SDL_SetVideoMode leak
==17685== 42 bytes in 2 blocks are definitely lost in loss record 46 of 78
==17685== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17685== by 0x4C454E92: (within /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C453746: (within /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C454693: _XimSetICValueData (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C45B160: _XimLocalCreateIC (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C43AA2B: XCreateIC (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4EF3F6C0: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EF3FA5A: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EF25181: SDL_SetVideoMode (in
/usr/lib/libSDL-1.2.so.0.7.3)

snd_pcm and snd_config leak
==17685== 120 bytes in 6 blocks are possibly lost in loss record 41 of 78
==17685== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17685== by 0x4424FDB7: snd_dlobj_cache_add (in /lib/libasound.so.2.0.0)
==17685== by 0x44257305: (within /lib/libasound.so.2.0.0)
==17685== by 0x4424CC10: (within /lib/libasound.so.2.0.0)
==17685== by 0x4424D742: snd_determine_driver (in
/lib/libasound.so.2.0.0)
==17685== by 0x4424A700: snd_config_hook_load_for_all_cards (in
/lib/libasound.so.2.0.0)
==17685== by 0x4424AA6A: (within /lib/libasound.so.2.0.0)
==17685== by 0x4424BA8B: snd_config_searcha_hooks (in
/lib/libasound.so.2.0.0)
==17685== by 0x4424BC1A: snd_config_search_alias_hooks (in
/lib/libasound.so.2.0.0)
==17685== by 0x4424BD3C: snd_config_search_definition (in
/lib/libasound.so.2.0.0)
==17685== by 0x4426FCFE: (within /lib/libasound.so.2.0.0)
==17685== by 0x4EF2BDEF: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685==
==17685==
==17685== 216 (36 direct, 180 indirect) bytes in 1 blocks are definitely
lost in loss record 45 of 78
==17685== at 0x400473F: calloc (vg_replace_malloc.c:279)
==17685== by 0x44246318: (within /lib/libasound.so.2.0.0)
==17685== by 0x44247428: snd_config_make (in /lib/libasound.so.2.0.0)
==17685== by 0x44247690: snd_config_make_compound (in
/lib/libasound.so.2.0.0)
==17685== by 0x4424771B: (within /lib/libasound.so.2.0.0)
==17685== by 0x44245C15: (within /lib/libasound.so.2.0.0)
==17685== by 0x4426AAF7: snd_pcm_slave_conf (in /lib/libasound.so.2.0.0)
==17685== by 0x442A2C57: _snd_pcm_dmix_open (in /lib/libasound.so.2.0.0)
==17685== by 0x4426F6B4: (within /lib/libasound.so.2.0.0)
==17685== by 0x4426FD37: (within /lib/libasound.so.2.0.0)
==17685== by 0x4426FDF2: snd_pcm_open_slave (in /lib/libasound.so.2.0.0)
==17685== by 0x442AC523: _snd_pcm_softvol_open (in
/lib/libasound.so.2.0.0)

Mix_SetPanning leak
==17797== 16 bytes in 1 blocks are definitely lost in loss record 12 of 81
==17797== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17797== by 0x4ED64610: Mix_RegisterEffect (in
/usr/lib/libSDL_mixer-1.2.so.0.2.5)
==17797== by 0x4ED61DE7: Mix_SetPanning (in
/usr/lib/libSDL_mixer-1.2.so.0.2.5)

Hope that helps,
k.>From my stuff, I’ve got leaks in both SDL and SDL_mixer.

SDL_InitSubSystem / SDL_AudioInit leak:
==17685== 25,812 bytes in 717 blocks are possibly lost in loss record 78
of 78
==17685== at 0x400473F: calloc (vg_replace_malloc.c:279)
==17685== by 0x44246318: (within /lib/libasound.so.2.0.0)

That’s a leak in ALSA.

SDL_SetVideoMode leak
==17685== 42 bytes in 2 blocks are definitely lost in loss record 46 of 78
==17685== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17685== by 0x4C454E92: (within /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C453746: (within /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C454693: _XimSetICValueData (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C45B160: _XimLocalCreateIC (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C43AA2B: XCreateIC (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4EF3F6C0: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EF3FA5A: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EF25181: SDL_SetVideoMode (in
/usr/lib/libSDL-1.2.so.0.7.3)

I think this was either a bug in Xlib, or there was some reason we
couldn’t free the structure. I’ll have to check.

snd_pcm and snd_config leak
==17685== 120 bytes in 6 blocks are possibly lost in loss record 41 of 78
==17685== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17685== by 0x4424FDB7: snd_dlobj_cache_add (in /lib/libasound.so.2.0.0)

ALSA bug.

==17685== 216 (36 direct, 180 indirect) bytes in 1 blocks are definitely
lost in loss record 45 of 78
==17685== at 0x400473F: calloc (vg_replace_malloc.c:279)
==17685== by 0x44246318: (within /lib/libasound.so.2.0.0)
==17685== by 0x44247428: snd_config_make (in /lib/libasound.so.2.0.0)

ALSA bug.

Mix_SetPanning leak
==17797== 16 bytes in 1 blocks are definitely lost in loss record 12 of 81
==17797== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17797== by 0x4ED64610: Mix_RegisterEffect (in
/usr/lib/libSDL_mixer-1.2.so.0.2.5)
==17797== by 0x4ED61DE7: Mix_SetPanning (in
/usr/lib/libSDL_mixer-1.2.so.0.2.5)

I can’t see a code path where that allocation wouldn’t get free()'d,
unless the program terminated without calling Mix_CloseAudio(). That
might explain some of the ALSA leaks, too.

–ryan.

I’m definitely calling Mix_CloseAudio().
I have just double checked by going through it in DDD.

Cheers,
Kos> ----- Original Message -----

From: sdl-bounces+kos=climaxgroup.com@libsdl.org
[mailto:sdl-bounces+kos=climaxgroup.com at libsdl.org] On Behalf Of Ryan C.
Gordon
Sent: 15 January 2007 14:10
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] SDL & SDL_mixer memory leaks

SDL_InitSubSystem / SDL_AudioInit leak:
==17685== 25,812 bytes in 717 blocks are possibly lost in loss record 78
of 78
==17685== at 0x400473F: calloc (vg_replace_malloc.c:279)
==17685== by 0x44246318: (within /lib/libasound.so.2.0.0)

That’s a leak in ALSA.

SDL_SetVideoMode leak
==17685== 42 bytes in 2 blocks are definitely lost in loss record 46 of 78
==17685== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17685== by 0x4C454E92: (within /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C453746: (within /usr/lib/libX11.so.6.2.0)
==17685== by 0x4C454693: _XimSetICValueData (in
/usr/lib/libX11.so.6.2.0)
==17685== by 0x4C45B160: _XimLocalCreateIC (in
/usr/lib/libX11.so.6.2.0)
==17685== by 0x4C43AA2B: XCreateIC (in /usr/lib/libX11.so.6.2.0)
==17685== by 0x4EF3F6C0: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EF3FA5A: (within /usr/lib/libSDL-1.2.so.0.7.3)
==17685== by 0x4EF25181: SDL_SetVideoMode (in
/usr/lib/libSDL-1.2.so.0.7.3)

I think this was either a bug in Xlib, or there was some reason we
couldn’t free the structure. I’ll have to check.

snd_pcm and snd_config leak
==17685== 120 bytes in 6 blocks are possibly lost in loss record 41 of 78
==17685== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17685== by 0x4424FDB7: snd_dlobj_cache_add (in
/lib/libasound.so.2.0.0)

ALSA bug.

==17685== 216 (36 direct, 180 indirect) bytes in 1 blocks are definitely
lost in loss record 45 of 78
==17685== at 0x400473F: calloc (vg_replace_malloc.c:279)
==17685== by 0x44246318: (within /lib/libasound.so.2.0.0)
==17685== by 0x44247428: snd_config_make (in /lib/libasound.so.2.0.0)

ALSA bug.

Mix_SetPanning leak
==17797== 16 bytes in 1 blocks are definitely lost in loss record 12 of 81
==17797== at 0x4005400: malloc (vg_replace_malloc.c:149)
==17797== by 0x4ED64610: Mix_RegisterEffect (in
/usr/lib/libSDL_mixer-1.2.so.0.2.5)
==17797== by 0x4ED61DE7: Mix_SetPanning (in
/usr/lib/libSDL_mixer-1.2.so.0.2.5)

I can’t see a code path where that allocation wouldn’t get free()'d,
unless the program terminated without calling Mix_CloseAudio(). That
might explain some of the ALSA leaks, too.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Kostas Kostiadis wrote:

I’m definitely calling Mix_CloseAudio().
I have just double checked by going through it in DDD.

Is there source code somewhere I can look at to track this down?

–ryan.

I’ll see if I can repro with a minimal example.
Do you want me to reply to the mailing list, or shall I send it to you own
email?

Cheers,
Kos> ----- Original Message -----

From: sdl-bounces+kos=climaxgroup.com@libsdl.org
[mailto:sdl-bounces+kos=climaxgroup.com at libsdl.org] On Behalf Of Ryan C.
Gordon
Sent: 15 January 2007 14:40
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] SDL & SDL_mixer memory leaks

Kostas Kostiadis wrote:

I’m definitely calling Mix_CloseAudio().
I have just double checked by going through it in DDD.

Is there source code somewhere I can look at to track this down?

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Kostas Kostiadis wrote:

I’ll see if I can repro with a minimal example.
Do you want me to reply to the mailing list, or shall I send it to you own
email?

Send it to me, if you would.

Thanks,
–ryan.