<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://svn.reviewboard.kde.org/r/7046/">http://svn.reviewboard.kde.org/r/7046/</a>
     </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On September 25th, 2012, 10:18 p.m., <b>Ian Wadham</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">That qDeleteAll() thing is deadly at times, it appears.  I believe it is a macro.  Does anyone here know what it expands to or how to find out?</pre>
 </blockquote>




 <p>On September 25th, 2012, 10:29 p.m., <b>Nemanja Hirsl</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">It can be found in qalgorithms.h:

template <typename ForwardIterator>
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
{
    while (begin != end) {
        delete *begin;
        ++begin;
    }
}

template <typename Container>
inline void qDeleteAll(const Container &c)
{
    qDeleteAll(c.begin(), c.end());
}</pre>
 </blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Grep is your friend

qalgorithms.h

template <typename ForwardIterator>
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
{
    while (begin != end) {
        delete *begin;
        ++begin;
    }
}

template <typename Container>
inline void qDeleteAll(const Container &c)
{
    qDeleteAll(c.begin(), c.end());
}

Plain iteration, there's nothing evil in it.</pre>
<br />








<p>- Albert</p>


<br />
<p>On September 25th, 2012, 9:55 p.m., Nemanja Hirsl wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://svn.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KDE Games.</div>
<div>By Nemanja Hirsl.</div>


<p style="color: grey;"><i>Updated Sept. 25, 2012, 9:55 p.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The analysis is the same as for bug 304362 and review: https://svn.reviewboard.kde.org/r/7045/
qDeleteAll crashes because of invalid iterators.
This time, qDeleteAll is called from libkdegames.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">1. New local game with 5 players
2. During the game, press 'x' to exit the game.
3. Game crashes with backtraces attached to bugs in summary.
Debug logs:
ksirk(9517) Ksirk::GameLogic::GameAutomaton::~GameAutomaton:
ksirk(9517)/libkdegames (KGame) KGame::~KGame:
ksirk(9517) Ksirk::GameLogic::AIPlayer::~AIPlayer: "Baudouin"
ksirk(9517)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x4304c30) , id= 1025
ksirk(9517)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x6b1f480)
ksirk(9517)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x6b1f480) delete= false
ksirk(9517)/libkdegames (KGame) KGame::playerDeleted: : id ( 1025 ) to be removed KPlayer(0x4304c30)
ksirk(9517)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9517)/libkdegames (KGame) KGame::systemRemove: : Player ( 1025 ) to be removed KPlayer(0x4304c30)
ksirk(9517)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1025
ksirk(9517)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9517) Ksirk::GameLogic::AIPlayer::~AIPlayer: "De Gaulle"
ksirk(9517)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x43070f0) , id= 1027
ksirk(9517)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x4770270)
ksirk(9517)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x4770270) delete= false
ksirk(9517)/libkdegames (KGame) KGame::playerDeleted: : id ( 1027 ) to be removed KPlayer(0x43070f0)
ksirk(9517)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9517)/libkdegames (KGame) KGame::systemRemove: : Player ( 1027 ) to be removed KPlayer(0x43070f0)
ksirk(9517)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1027
ksirk(9517)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9517)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x4313130) , id= 1029
ksirk(9517)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x430c730)
ksirk(9517)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x430c730) delete= false
ksirk(9517)/libkdegames (KGame) KGame::playerDeleted: : id ( 1029 ) to be removed KPlayer(0x4313130)
ksirk(9517)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9517)/libkdegames (KGame) KGame::systemRemove: : Player ( 1029 ) to be removed KPlayer(0x4313130)
ksirk(9517)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1029
ksirk(9517)/libkdegames (KGame) KPlayer::~KPlayer: done
KCrash: Application 'ksirk' crashing...


After patch applied, same test case is not crashing anymore.

Debug logs:
ksirk(9848) Ksirk::GameLogic::GameAutomaton::~GameAutomaton:
ksirk(9848)/libkdegames (KGame) KGame::~KGame:
ksirk(9848) Ksirk::GameLogic::AIPlayer::~AIPlayer: "Baudouin"
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x3ff4120) , id= 1025
ksirk(9848)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x3ff4700)
ksirk(9848)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x3ff4700) delete= false
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : id ( 1025 ) to be removed KPlayer(0x3ff4120)
ksirk(9848)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9848)/libkdegames (KGame) KGame::systemRemove: : Player ( 1025 ) to be removed KPlayer(0x3ff4120)
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1025
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9848) Ksirk::GameLogic::AIPlayer::~AIPlayer: "de Gaulle"
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x40330f0) , id= 1026
ksirk(9848)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x3ff4590)
ksirk(9848)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x3ff4590) delete= false
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : id ( 1026 ) to be removed KPlayer(0x40330f0)
ksirk(9848)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9848)/libkdegames (KGame) KGame::systemRemove: : Player ( 1026 ) to be removed KPlayer(0x40330f0)
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1026
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9848) Ksirk::GameLogic::AIPlayer::~AIPlayer: "Victor Emmanuel"
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x4032be0) , id= 1027
ksirk(9848)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x4ab86e0)
ksirk(9848)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x4ab86e0) delete= false
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : id ( 1027 ) to be removed KPlayer(0x4032be0)
ksirk(9848)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9848)/libkdegames (KGame) KGame::systemRemove: : Player ( 1027 ) to be removed KPlayer(0x4032be0)
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1027
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9848) Ksirk::GameLogic::AIPlayer::~AIPlayer: "Akihito"
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x4039450) , id= 1028
ksirk(9848)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x4033f20)
ksirk(9848)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x4033f20) delete= false
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : id ( 1028 ) to be removed KPlayer(0x4039450)
ksirk(9848)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9848)/libkdegames (KGame) KGame::systemRemove: : Player ( 1028 ) to be removed KPlayer(0x4039450)
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1028
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: : this= KPlayer(0x4034330) , id= 1029
ksirk(9848)/libkdegames (KGame) KGameIO::~KGameIO: : this= KGameIO(0x403ac40)
ksirk(9848)/libkdegames (KGame) KPlayer::removeGameIO: : KGameIO(0x403ac40) delete= false
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : id ( 1029 ) to be removed KPlayer(0x4034330)
ksirk(9848)/libkdegames (KGame) KGame::systemRemovePlayer:
ksirk(9848)/libkdegames (KGame) KGame::systemRemove: : Player ( 1029 ) to be removed KPlayer(0x4034330)
ksirk(9848)/libkdegames (KGame) KGame::playerDeleted: : sending IdRemovePlayer  1029
ksirk(9848)/libkdegames (KGame) KPlayer::~KPlayer: done
ksirk(9848)/libkdegames (KGame) KGame::~KGame: done
ksirk(9848)/libkdegames (KGame) KGameNetwork::~KGameNetwork: this= KGameNetwork(0x20217d0)
ksirk(9848)/libkdegames (KGame) KMessageServer::~KMessageServer: this= KMessageServer(0x1fc0210)
ksirk(9848)/libkdegames (KGame) KMessageServer::Debug: ------------------ KMESSAGESERVER -----------------------
ksirk(9848)/libkdegames (KGame) KMessageServer::Debug: MaxClients :    -1
ksirk(9848)/libkdegames (KGame) KMessageServer::Debug: NoOfClients :   1
ksirk(9848)/libkdegames (KGame) KMessageServer::Debug: ---------------------------------------------------
ksirk(9848)/libkdegames (KGame) KMessageClient::removeBrokenConnection: : timer single shot for removeBrokenConnection KMessageClient(0x1fbfcf0)
ksirk(9848)/libkdegames (KGame) KMessageServer::~KMessageServer: done
ksirk(9848) Ksirk::FightArena::~FightArena:
ksirk(9848)/libkdegames (KGame) KGameChat::~KGameChat:
</pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/trunk/KDE/kdegames/libkdegames/libkdegamesprivate/kgame/kgame.cpp <span style="color: grey">(1309567)</span></li>

</ul>

<p><a href="http://svn.reviewboard.kde.org/r/7046/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>