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 3238 - Memleak in linux haptic code [patch]
Summary: Memleak in linux haptic code [patch]
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: haptic (show other bugs)
Version: 2.0.4
Hardware: All Linux
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-13 07:35 UTC by Martin Gerhardy
Modified: 2016-07-20 19:22 UTC (History)
1 user (show)

See Also:


Attachments
memleak fix (458 bytes, patch)
2016-01-13 07:37 UTC, Martin Gerhardy
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Gerhardy 2016-01-13 07:35:24 UTC
the attached patch fixes a memleak in the linux haptic code
Comment 1 Martin Gerhardy 2016-01-13 07:37:09 UTC
=================================================================
==16438==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f8cdb58eb49 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98b49)
    #1 0xaddf72 in SDL_calloc_REAL /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/stdlib/SDL_malloc.c:41
    #2 0xb3e833 in MaybeAddDevice /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/haptic/linux/SDL_syshaptic.c:278
    #3 0xb3e483 in SDL_SYS_HapticInit /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/haptic/linux/SDL_syshaptic.c:172
    #4 0xb2def7 in SDL_HapticInit /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/haptic/SDL_haptic.c:39
    #5 0xb4efdc in SDL_InitSubSystem_REAL /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/SDL.c:228
    #6 0xb4f00d in SDL_Init_REAL /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/SDL.c:244
    #7 0xa8666a in SDL_Init /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/dynapi/SDL_dynapi_procs.h:89
    #8 0x7ce69b in SDLFrontend::init(int, int, bool, EventHandler&) /home/mgerhardy/dev/caveexpress/src/modules/gfx/SDLFrontend.cpp:561
    #9 0x798162 in SDLBackend::handleInit() /home/mgerhardy/dev/caveexpress/src/modules/server/SDLBackend.cpp:240
    #10 0x798a17 in SDLBackend::runFrame() /home/mgerhardy/dev/caveexpress/src/modules/server/SDLBackend.cpp:297
    #11 0x79961f in SDLBackend::mainLoop(int, char**) /home/mgerhardy/dev/caveexpress/src/modules/server/SDLBackend.cpp:357
    #12 0x6adc48 in main /home/mgerhardy/dev/caveexpress/src/Main.cpp:31
    #13 0x7f8cd98fba3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)

Indirect leak of 96 byte(s) in 3 object(s) allocated from:
    #0 0x7f8cdb58eb49 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98b49)
    #1 0xaddf72 in SDL_calloc_REAL /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/stdlib/SDL_malloc.c:41
    #2 0xb3e833 in MaybeAddDevice /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/haptic/linux/SDL_syshaptic.c:278
    #3 0xb3e483 in SDL_SYS_HapticInit /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/haptic/linux/SDL_syshaptic.c:172
    #4 0xb2def7 in SDL_HapticInit /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/haptic/SDL_haptic.c:39
    #5 0xb4efdc in SDL_InitSubSystem_REAL /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/SDL.c:228
    #6 0xb4f00d in SDL_Init_REAL /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/SDL.c:244
    #7 0xa8666a in SDL_Init /home/mgerhardy/dev/caveexpress/src/libs/sdl2/src/dynapi/SDL_dynapi_procs.h:89
    #8 0x7ce69b in SDLFrontend::init(int, int, bool, EventHandler&) /home/mgerhardy/dev/caveexpress/src/modules/gfx/SDLFrontend.cpp:561
    #9 0x798162 in SDLBackend::handleInit() /home/mgerhardy/dev/caveexpress/src/modules/server/SDLBackend.cpp:240
    #10 0x798a17 in SDLBackend::runFrame() /home/mgerhardy/dev/caveexpress/src/modules/server/SDLBackend.cpp:297
    #11 0x79961f in SDLBackend::mainLoop(int, char**) /home/mgerhardy/dev/caveexpress/src/modules/server/SDLBackend.cpp:357
    #12 0x6adc48 in main /home/mgerhardy/dev/caveexpress/src/Main.cpp:31
    #13 0x7f8cd98fba3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)

SUMMARY: AddressSanitizer: 128 byte(s) leaked in 4 allocation(s).
Comment 2 Martin Gerhardy 2016-01-13 07:37:45 UTC
Created attachment 2363 [details]
memleak fix
Comment 3 Philipp Wiesemann 2016-01-13 18:53:07 UTC
There is a comment in SDL_SYS_HapticQuit() telling that something should leak. :)
Comment 4 Martin Gerhardy 2016-01-13 21:08:09 UTC
Well, I think this relates to the haptic structures that are attached to the item - but not to the item itself. The item is afaik nowhere else referenced, and why should some mem be leaked on purpose?
Comment 5 Philipp Wiesemann 2016-01-13 22:08:10 UTC
No idea. I did not understand the source comment then (but you are right :). Sorry.
Comment 6 Philipp Wiesemann 2016-07-20 19:22:26 UTC
This patch is now https://hg.libsdl.org/SDL/rev/afd286e26823, thanks!