Skip to content

Fix some memory leakages

Will forward-port to master directly.

@aacid @heikobecker

One found by valgrind, one by hardened_malloc crash backtrace (thanks to @heikobecker for giving logs). Examples:

==349341== 96 (32 direct, 64 indirect) bytes in 1 blocks are definitely lost in loss record 2,115 of 2,217
==349341==    at 0x483FF3F: operator new(unsigned long) (vg_replace_malloc.c:472)
==349341==    by 0x48EC32A: KMessageServer::getReceivedMessage(QByteArray const&) (kmessageserver.cpp:353)
==349341==    by 0x5D97F8F: UnknownInlinedFun (qobjectdefs_impl.h:433)
==349341==    by 0x5D97F8F: void doActivate<false>(QObject*, int, void**) (qobject.cpp:4021)
==349341==    by 0x48E89D1: KMessageIO::received(QByteArray const&) (moc_kmessageio.cpp:195)
==349341==    by 0x48EF279: KMessageClient::sendBroadcast(QByteArray const&) (kmessageclient.cpp:145)
==349341==    by 0x48E6EA7: KGameNetwork::sendSystemMessage(QByteArray const&, int, unsigned int, unsigned int) (kgamenetwork.cpp:428)
==349341==    by 0x48D88B4: KGame::sendProperty(int, QDataStream&, bool*) (kgame.cpp:1362)
==349341==    by 0x5D98234: void doActivate<false>(QObject*, int, void**) (qobject.cpp:4033)
==349341==    by 0x48DF091: KGamePropertyHandler::signalSendMessage(int, QDataStream&, bool*) (moc_kgamepropertyhandler.cpp:237)
==349341==    by 0x48E34C7: KGamePropertyHandler::sendProperty(QDataStream&) (kgamepropertyhandler.cpp:325)
==349341==    by 0x48E384A: KGamePropertyBase::sendProperty(QByteArray const&) (kgameproperty.cpp:140)
==349341==    by 0x48D810A: UnknownInlinedFun (kgameproperty.h:709)
==349341==    by 0x48D810A: UnknownInlinedFun (kgameproperty.h:698)
==349341==    by 0x48D810A: UnknownInlinedFun (kgameproperty.h:774)
==349341==    by 0x48D810A: UnknownInlinedFun (kgame.cpp:630)
==349341==    by 0x48D810A: KGame::setMaxPlayers(unsigned int) (kgame.cpp:627)

and

#6  0x00007f67944be16c in __pthread_kill_implementation () from /usr/x86_64-pc-linux-gnu/lib/libc.so.6
#7  0x00007f679446eb36 in raise () from /usr/x86_64-pc-linux-gnu/lib/libc.so.6
#8  0x00007f6794457835 in abort () from /usr/x86_64-pc-linux-gnu/lib/libc.so.6
#9  0x00007f67964ab0d9 in fatal_error () from /usr/x86_64-pc-linux-gnu/lib/libhardened_malloc-light.so
#10 0x00007f67964ab223 in deallocate_small[cold] () from /usr/x86_64-pc-linux-gnu/lib/libhardened_malloc-light.so
#11 0x00007f67964ae028 in free_sized () from /usr/x86_64-pc-linux-gnu/lib/libhardened_malloc-light.so
#12 0x00007f67964ae8da in operator delete(void*, unsigned long) () from /usr/x86_64-pc-linux-gnu/lib/libhardened_malloc-light.so
#13 0x00007f679641a38d in std::default_delete<KGameIOPrivate>::operator() (__ptr=<optimized out>, this=<optimized out>) at /usr/x86_64-pc-linux-gnu/include/c++/13/bits/unique_ptr.h:93
#14 std::unique_ptr<KGameIOPrivate, std::default_delete<KGameIOPrivate> >::~unique_ptr (this=<optimized out>, this=<optimized out>) at /usr/x86_64-pc-linux-gnu/include/c++/13/bits/unique_ptr.h:404
#15 KGameIO::~KGameIO (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-libkdegames-scm/work/libkdegames-scm/src/private/kgame/kgameio.cpp:65
#16 0x00007f679641a909 in KGameProcessIO::~KGameProcessIO (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-libkdegames-scm/work/libkdegames-scm/src/private/kgame/kgameio.cpp:304
#17 0x00007f6796432996 in qDeleteAll<QList<KGameIO*>::const_iterator> (end=..., begin=...) at /usr/x86_64-pc-linux-gnu/include/qt6/QtCore/qalgorithms.h:27
#18 qDeleteAll<QList<KGameIO*> > (c=...) at /usr/x86_64-pc-linux-gnu/include/qt6/QtCore/qalgorithms.h:35
#19 KPlayer::~KPlayer (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-libkdegames-scm/work/libkdegames-scm/src/private/kgame/kplayer.cpp:99
#20 0x000055824dc91a79 in KWin4Player::~KWin4Player (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-kfourinline-scm/work/kfourinline-scm/src/kwin4player.cpp:48
#21 0x00007f679640c962 in KGame::deletePlayers (this=this@entry=0x741893983300) at /var/tmp/paludis/build/kde-libkdegames-scm/work/libkdegames-scm/src/private/kgame/kgame.cpp:142
#22 0x00007f679640ca99 in KGame::reset (this=this@entry=0x741893983300) at /var/tmp/paludis/build/kde-libkdegames-scm/work/libkdegames-scm/src/private/kgame/kgame.cpp:130
#23 0x00007f679640f454 in KGame::~KGame (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-libkdegames-scm/work/libkdegames-scm/src/private/kgame/kgame.cpp:119
#24 0x000055824dc81063 in KWin4Doc::~KWin4Doc (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-kfourinline-scm/work/kfourinline-scm/src/kwin4doc.cpp:112
#25 KWin4App::~KWin4App (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-kfourinline-scm/work/kfourinline-scm/src/kwin4.cpp:160
#26 0x000055824dc81399 in KWin4App::~KWin4App (this=<optimized out>, this=<optimized out>) at /var/tmp/paludis/build/kde-kfourinline-scm/work/kfourinline-scm/src/kwin4.cpp:166

Merge request reports

Loading