-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>
Please submit this patch as a bug ticket. Thanks! |
@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>
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 |
This was referenced Apr 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.