Opened 6 years ago

Last modified 3 years ago

#10397 new defect

FULLPIPE: Memory leak when loading a saved game

Reported by: dafioram Owned by:
Priority: low Component: Engine: NGI
Version: Keywords:
Cc: Game: Full Pipe

Description

cf1171d4d9b43eba525439da82db16cd4aac0414

Running valgrind:

Loading a save via gmm:

==19513== 44,248 (112 direct, 44,136 indirect) bytes in 1 blocks are definitely lost in loss record 2,490 of 2,490
==19513==    at 0x4C2E19F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19513==    by 0x1B1801: Fullpipe::createObject(int) (utils.cpp:320)
==19513==    by 0x1B336D: Fullpipe::MfcArchive::parseClass(bool*) (utils.cpp:410)
==19513==    by 0x1B39C2: Fullpipe::MfcArchive::readBaseClass() (utils.cpp:375)
==19513==    by 0x1A791C: readClass<Fullpipe::GameVar> (utils.h:66)
==19513==    by 0x1A791C: Fullpipe::GameLoader::readSavegame(char const*) (stateloader.cpp:87)
==19513==    by 0x16AF2B: Fullpipe::FullpipeEngine::loadGameState(int) (fullpipe.cpp:236)
==19513==    by 0x16BBEC: Fullpipe::FullpipeEngine::run() (fullpipe.cpp:286)
==19513==    by 0x158CA5: runGame (main.cpp:264)
==19513==    by 0x158CA5: scummvm_main (main.cpp:530)
==19513==    by 0x1532AD: main (posix-main.cpp:45)

Starting game and loading a save using in game menu (not gmm):

==19982== 44,248 (112 direct, 44,136 indirect) bytes in 1 blocks are definitely lost in loss record 2,492 of 2,492
==19982==    at 0x4C2E19F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19982==    by 0x1B1801: Fullpipe::createObject(int) (utils.cpp:320)
==19982==    by 0x1B336D: Fullpipe::MfcArchive::parseClass(bool*) (utils.cpp:410)
==19982==    by 0x1B39C2: Fullpipe::MfcArchive::readBaseClass() (utils.cpp:375)
==19982==    by 0x1A61C7: readClass<Fullpipe::GameVar> (utils.h:66)
==19982==    by 0x1A61C7: Fullpipe::GameVar::load(Fullpipe::MfcArchive&) (stateloader.cpp:474)
==19982==    by 0x1B39DC: Fullpipe::MfcArchive::readBaseClass() (utils.cpp:378)
==19982==    by 0x1A61C7: readClass<Fullpipe::GameVar> (utils.h:66)
==19982==    by 0x1A61C7: Fullpipe::GameVar::load(Fullpipe::MfcArchive&) (stateloader.cpp:474)
==19982==    by 0x1B39DC: Fullpipe::MfcArchive::readBaseClass() (utils.cpp:378)
==19982==    by 0x1A61C7: readClass<Fullpipe::GameVar> (utils.h:66)
==19982==    by 0x1A61C7: Fullpipe::GameVar::load(Fullpipe::MfcArchive&) (stateloader.cpp:474)
==19982==    by 0x1B39DC: Fullpipe::MfcArchive::readBaseClass() (utils.cpp:378)
==19982==    by 0x1A6235: readClass<Fullpipe::GameVar> (utils.h:66)
==19982==    by 0x1A6235: Fullpipe::GameVar::load(Fullpipe::MfcArchive&) (stateloader.cpp:476)
==19982==    by 0x1B39DC: Fullpipe::MfcArchive::readBaseClass() (utils.cpp:378)

Start game and don't load a save:

No memory leak.

Change History (2)

comment:1 by digitall, 5 years ago

commit cf1171d4d9b43eba525439da82db16cd4aac0414 is "MOHAWK: RIVEN: Rewind videos that are played until their end" from 2018-01-01 18:57:03.

These memory leaks are still occuring in the current git master, though due to code changes / fixes to the Fullpipe engine in the interim, the line numbers do not exactly match up from the above trace.

This is quite tricky to fix as the leakage is occurring from GameVar objects created when loading a savegame. These should all be freed correctly when exiting, but they are held in a doubly linked list structure from which nodes can be deleted and I am not clear in what cases when this is done if the node can be deleted/freed.

This will need some careful and deep analysis of the save / load and engine variable code to fix this without accidently freeing actively used variables and thus causing crash / breakage.

comment:2 by digitall, 3 years ago

Component: Engine: FullpipeEngine: NGI
Note: See TracTickets for help on using tickets.