ReinhardPrix / FreedroidClassic

The original Freedroid, a free & open-source clone of the C64 classic 'Paradroid'.
GNU General Public License v2.0
39 stars 6 forks source link

fixed a gazillion of 'memory leaks' #18

Closed ReinhardPrix closed 6 years ago

ReinhardPrix commented 6 years ago
ReinhardPrix commented 6 years ago

I think I got all of them (using valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all), but it's a bit hard to tell with the 'noise' that produces.

matthiaskrgr commented 6 years ago

Ah nevermind, the crash happens when starting the game as ./src/freedroid from the root directory and not the src directory

matthiaskrgr commented 6 years ago

Ok, I still have these leaks for example

Direct leak of 127744 byte(s) in 16 object(s) allocated from:
    #0 0x31326a in __interceptor_calloc /home/matthias/LLVM/LLVM6/stage_2/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:97:3
    #1 0x3a69bc in MyMalloc /tmp/FreedroidClassic/src/misc.c:1086:15
    #2 0x390519 in LoadShip /tmp/FreedroidClassic/src/map.c:287:30
    #3 0x3774e3 in InitNewMission /tmp/FreedroidClassic/src/init.c:689:8
    #4 0x38c439 in main /tmp/FreedroidClassic/src/main.c:86:7

Indirect leak of 6993 byte(s) in 217 object(s) allocated from:
    #0 0x31326a in __interceptor_calloc /home/matthias/LLVM/LLVM6/stage_2/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:97:3
    #1 0x3a69bc in MyMalloc /tmp/FreedroidClassic/src/misc.c:1086:15
    #2 0x390519 in LoadShip /tmp/FreedroidClassic/src/map.c:287:30
    #3 0x3774e3 in InitNewMission /tmp/FreedroidClassic/src/init.c:689:8
    #4 0x38c439 in main /tmp/FreedroidClassic/src/main.c:86:7
ReinhardPrix commented 6 years ago

ah, ok, still shouldn't crash, I'll update the pull request with a fix

ReinhardPrix commented 6 years ago

mh, so using the sanitizer tool (clang-6.0) I can't reproduce any leaks that are obviously coming from Freedroid, instead I'm getting only

==28523==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 152 byte(s) in 2 object(s) allocated from:
    #0 0x4e0b88 in realloc (/home/repr/Software/development/FreeDroid/freedroid-GIT/src/freedroid+0x4e0b88)
    #1 0x7f8a64e8769c  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x5569c)

Direct leak of 20 byte(s) in 2 object(s) allocated from:
    #0 0x4459e0 in __strdup (/home/repr/Software/development/FreeDroid/freedroid-GIT/src/freedroid+0x4459e0)
    #1 0x7f8a64e9f996  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x6d996)

Direct leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x4e0718 in __interceptor_malloc (/home/repr/Software/development/FreeDroid/freedroid-GIT/src/freedroid+0x4e0718)
    #1 0x7f8a64e91084 in _XlcDefaultMapModifiers (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x5f084)

Indirect leak of 1520 byte(s) in 19 object(s) allocated from:
    #0 0x4e0930 in calloc (/home/repr/Software/development/FreeDroid/freedroid-GIT/src/freedroid+0x4e0930)
    #1 0x7f8a64e8766e  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x5566e)

Indirect leak of 128 byte(s) in 16 object(s) allocated from:
    #0 0x4e0718 in __interceptor_malloc (/home/repr/Software/development/FreeDroid/freedroid-GIT/src/freedroid+0x4e0718)
    #1 0x7f8a64e880ed  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x560ed)

Indirect leak of 80 byte(s) in 3 object(s) allocated from:
    #0 0x4e0b88 in realloc (/home/repr/Software/development/FreeDroid/freedroid-GIT/src/freedroid+0x4e0b88)
    #1 0x7f8a64e88030  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x56030)

SUMMARY: AddressSanitizer: 1901 byte(s) leaked in 43 allocation(s).

which looks like it's coming from some support libraries (SDL?).