Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init memleak fixes #30

Closed
wants to merge 5 commits into from
Closed

Init memleak fixes #30

wants to merge 5 commits into from

Conversation

T-X
Copy link
Contributor

@T-X T-X commented Apr 10, 2012

These should fix some non critical memory leaks which were caused by memory allocated during startup but Not being properly freed during shutdown. They are shown when starting warzone2100 with "valgrind --leak-check=full" and hitting "Quit Game" right afterwards.

Refs #3395 (http://developer.wz2100.net/ticket/3395).

Fixes #3399.

After those four patches, the following two valgrind errors are still left during this minimal startup phase for me:

==12304== 40 bytes in 1 blocks are still reachable in loss record 209 of 642
==12304== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12304== by 0x781916: __glcGetThreadArea (in /mnt/dev/warzone2100/src/warzone2100)
==12304== by 0x77EDF0: __glcLock (in /mnt/dev/warzone2100/src/warzone2100)
==12304== by 0x78487A: __glcContextCreate (in /mnt/dev/warzone2100/src/warzone2100)
==12304== by 0x77F3FE: glcGenContext (in /mnt/dev/warzone2100/src/warzone2100)
==12304== by 0x756AFC: iV_initializeGLC() (textdraw.cpp:123)
==12304== by 0x756DFC: iV_TextInit() (textdraw.cpp:205)
==12304== by 0x5A89FF: systemInitialise() (init.cpp:521)
==12304== by 0x5D115B: realmain(int, char**) (main.cpp:1278)
==12304== by 0x792183: main (main_sdl.cpp:24)
==12304==
==12304== 84 bytes in 2 blocks are still reachable in loss record 381 of 642
==12304== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12304== by 0x400AA85: _dl_new_object (dl-object.c:161)
==12304== by 0x4005FB5: _dl_map_object_from_fd (dl-load.c:957)
==12304== by 0x40076B7: _dl_map_object (dl-load.c:2468)
==12304== by 0x400CF61: openaux (dl-deps.c:65)
==12304== by 0x400D925: _dl_catch_error (dl-error.c:178)
==12304== by 0x400C02B: _dl_map_object_deps (dl-deps.c:247)
==12304== by 0x4011EB7: dl_open_worker (dl-open.c:263)
==12304== by 0x400D925: _dl_catch_error (dl-error.c:178)
==12304== by 0x4011899: _dl_open (dl-open.c:633)
==12304== by 0x8E1DF65: dlopen_doit (dlopen.c:67)
==12304== by 0x400D925: _dl_catch_error (dl-error.c:178)
==12304==

But I can't tell yet, whether they are warzone2100's fault or external issues. For the former, looking at the QuesoGLC 0.7.2 documentation and source code as well as some printf'ing in the Warzone2100 code it looked more like a bug in the external glcDeleteContext() function which as far as I can tell is properly called from the warzone2100 side. For the latter - no idea where that comes from.

T-X added 4 commits April 10, 2012 05:40
This fixes a veeery large and serious memory leak :P. And removes an
error reported by valgrind like the following one:

==28073== 1 bytes in 1 blocks are still reachable in loss record 1 of 1,007
==28073==    at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28073==    by 0x8821881: strdup (strdup.c:43)
==28073==    by 0x7291EB: NETinit(bool) (netplay.cpp:1052)
==28073==    by 0x5D0C27: realmain(int, char**) (main.cpp:1165)
==28073==    by 0x791E8F: main (main_sdl.cpp:24)

Refs Warzone2100#3395.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
The EffectChunks are not being freed before quitting the game. This
patch should fix that. This removes errors reported in valgrind like the
following one:

==28073== 1,120,008 bytes in 1 blocks are possibly lost in loss record 1,007 of 1,007
==28073==    at 0x4027034: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28073==    by 0x54CF73: initEffectsSystem() (effects.cpp:403)
==28073==    by 0x5E27FC: startMission(LEVEL_TYPE, char*) (mission.cpp:432)
==28073==    by 0x5C908C: levLoadData(char const*, char*, GAME_TYPE) (levels.cpp:932)
==28073==    by 0x5D0274: startGameLoop() (main.cpp:782)
==28073==    by 0x5D0723: runTitleLoop() (main.cpp:971)
==28073==    by 0x5D0841: mainLoop() (main.cpp:1014)
==28073==    by 0x793EE2: wzMain3() (main_sdl.cpp:1257)
==28073==    by 0x5D11A1: realmain(int, char**) (main.cpp:1313)
==28073==    by 0x791E8F: main (main_sdl.cpp:24)

Refs Warzone2100#3395.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Net queues and the broadcast queue are not being freed before quitting
the game. This patch should fix that. This removes errors reported in
valgrind like the following ones:

==9429== 1,408 bytes in 11 blocks are still reachable in loss record 586 of 648
==9429==    at 0x4028447: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9429==    by 0x746495: NETinitQueue(NETQUEUE) (nettypes.cpp:419)
==9429==    by 0x726E4B: NET_InitPlayers() (netplay.cpp:301)
==9429==    by 0x72926F: NETinit(bool) (netplay.cpp:1037)
==9429==    by 0x5D0C8B: realmain(int, char**) (main.cpp:1165)
==9429==    by 0x791F9F: main (main_sdl.cpp:24)

or:

==9429== 64 bytes in 1 blocks are still reachable in loss record 276 of 648
==9429==    at 0x4028447: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9429==    by 0x7463E2: NETinitQueue(NETQUEUE) (nettypes.cpp:406)
==9429==    by 0x726E8C: NET_InitPlayers() (netplay.cpp:303)
==9429==    by 0x72926F: NETinit(bool) (netplay.cpp:1037)
==9429==    by 0x5D0C8B: realmain(int, char**) (main.cpp:1165)
==9429==    by 0x791F9F: main (main_sdl.cpp:24)

Refs Warzone2100#3395.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
dbgHeader is not being freed before quitting the game. This patch should
fix that. This removes errors reported by valgrind like the following
one:

==10690== 604 bytes in 1 blocks are still reachable in loss record 492 of 643
==10690==    at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10690==    by 0x8821881: strdup (strdup.c:43)
==10690==    by 0x7723D0: createHeader(int, char const**, char const*) (dumpinfo.cpp:327)
==10690==    by 0x772656: dbgDumpInit(int, char const**, char const*) (dumpinfo.cpp:357)
==10690==    by 0x775DDD: setupExceptionHandler(int, char const**, char const*) (exceptionhandler.cpp:747)
==10690==    by 0x5D09FE: realmain(int, char**) (main.cpp:1097)
==10690==    by 0x7920B3: main (main_sdl.cpp:24)

Refs Warzone2100#3395.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
@perim
Copy link
Member

perim commented Apr 10, 2012

Please submit this patch as a bug ticket. Thanks!

@dak180
Copy link
Contributor

dak180 commented Apr 10, 2012

@perim Should this be on the bugfixes branch or just in master?

NETinitQueue does take care of correctly deleting old game queues before
initializing new ones (i.e. upon game round restarts). However gameQueues
do not get freed when quitting warzone2100. This patch should fix that.
This removes errors reported by valgrind like the following ones which
occure after having started at least one game round:

==4147== 704 bytes in 11 blocks are still reachable in loss record 582 of 755
==4147==    at 0x4028447: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4147==    by 0x74F02C: NETinitQueue(NETQUEUE) (nettypes.cpp:413)
==4147==    by 0x5A9A79: stageTwoInitialise() (init.cpp:1003)
==4147==    by 0x5C91B6: levLoadData(char const*, char*, GAME_TYPE) (levels.cpp:832)
==4147==    by 0x5D0914: startGameLoop() (main.cpp:782)
==4147==    by 0x5D0DC3: runTitleLoop() (main.cpp:971)
==4147==    by 0x5D0EE1: mainLoop() (main.cpp:1014)
==4147==    by 0x79CC86: wzMain3() (main_sdl.cpp:1257)
==4147==    by 0x5D185F: realmain(int, char**) (main.cpp:1315)
==4147==    by 0x79AC33: main (main_sdl.cpp:24)

or:

==4147== 960 bytes in 20 blocks are still reachable in loss record 649 of 755
==4147==    at 0x4028447: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4147==    by 0x746D30: __gnu_cxx::new_allocator<std::_List_node<NetMessage> >::allocate(unsigned long, void const*) (new_allocator.h:92)
==4147==    by 0x74688B: std::_List_base<NetMessage, std::allocator<NetMessage> >::_M_get_node() (stl_list.h:327)
==4147==    by 0x7461FA: std::list<NetMessage, std::allocator<NetMessage> >::_M_create_node(NetMessage const&) (stl_list.h:473)
==4147==    by 0x745922: std::list<NetMessage, std::allocator<NetMessage> >::_M_insert(std::_List_iterator<NetMessage>, NetMessage const&) (stl_list.h:1515)
==4147==    by 0x745431: std::list<NetMessage, std::allocator<NetMessage> >::push_front(NetMessage const&) (stl_list.h:947)
==4147==    by 0x744D1E: NetQueue::pushMessage(NetMessage const&) (netqueue.cpp:192)
==4147==    by 0x74F4B3: NETend() (nettypes.cpp:476)
==4147==    by 0x76A588: sendPlayerGameTime() (gtime.cpp:379)
==4147==    by 0x5CDF50: gameStateUpdate() (loop.cpp:434)
==4147==    by 0x5CE6E7: gameLoop() (loop.cpp:674)
==4147==    by 0x5D0BDA: runGameLoop() (main.cpp:905)

Refs Warzone2100#3395.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
@vexed
Copy link
Member

vexed commented Feb 5, 2014

Hi, we really dislike github's mere/pull request, our bug tracker @ http://developer.wz2100.net would be the correct venue for these things, as explained in http://forums.wz2100.net/viewtopic.php?f=1&t=11570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants