<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://git.reviewboard.kde.org/r/109285/">http://git.reviewboard.kde.org/r/109285/</a>
     </td>
    </tr>
   </table>
   <br />



 <p>Ship it!</p>



 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">As discussed on IRC, it would be better for Renderer to not be a global/singleton at all; but this is definitely an improvement.</pre>
 <br />









<p>- Nicolas</p>


<br />
<p>On March 4th, 2013, 10:53 p.m. UTC, Albert Astals Cid wrote:</p>








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

<div>Review request for KDE Games and Parker Coates.</div>
<div>By Albert Astals Cid.</div>


<p style="color: grey;"><i>Updated March 4, 2013, 10:53 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;">As we can see in build.kde.org the test crashes sometimes http://build.kde.org/view/kdegames/job/killbots_master/20/testReport/%28root%29/TestSuite/enginetest/

I managed to reproduce it locally and the backtrace is

#0  ref (this=0x0) at ../../include/QtCore/../../src/corelib/arch/qatomic_x86_64.h:121
#1  QPen::QPen (this=0x7f77540d46d0) at painting/qpen.cpp:280
#2  0x00007f77649022a3 in QSvgStrokeStyle::QSvgStrokeStyle (this=0x7f77540d46c0) at qsvgstyle.cpp:291
#3  0x00007f77648f2d85 in parsePen (handler=0x7f775b961960, attributes=..., node=0x7f77540d39b0) at qsvghandler.cpp:1172
#4  parseStyle (handler=0x7f775b961960, attributes=..., node=0x7f77540d39b0) at qsvghandler.cpp:2216
#5  parseStyle (node=node@entry=0x7f77540d39b0, attrs=..., handler=handler@entry=0x7f775b961960) at qsvghandler.cpp:2257
#6  0x00007f77648f73b4 in QSvgHandler::startElement (this=this@entry=0x7f775b961960, localName=..., attributes=...) at qsvghandler.cpp:3673
#7  0x00007f77648f9960 in QSvgHandler::parse (this=this@entry=0x7f775b961960) at qsvghandler.cpp:3559
#8  0x00007f77648f9bfd in QSvgHandler::init (this=this@entry=0x7f775b961960) at qsvghandler.cpp:3539
#9  0x00007f77648f9e06 in QSvgHandler::QSvgHandler (this=0x7f775b961960, data=...) at qsvghandler.cpp:3522
#10 0x00007f7764905dad in QSvgTinyDocument::load (contents=...) at qsvgtinydocument.cpp:208
#11 0x00007f7764905ec8 in QSvgTinyDocument::load (fileName=...) at qsvgtinydocument.cpp:182
#12 0x00007f7764908db7 in loadDocument<QString> (in=..., d=0x7f7754005350, q=0x7f7754005330) at qsvgrenderer.cpp:317
#13 QSvgRenderer::load (this=this@entry=0x7f7754005330, filename=...) at qsvgrenderer.cpp:343
#14 0x00007f7764908f3d in QSvgRenderer::QSvgRenderer (this=0x7f7754005330, filename=..., parent=0x0) at qsvgrenderer.cpp:140
#15 0x00007f7768d2bfc8 in KGRInternal::RendererPool::allocRenderer (this=0x1b327c0) at /home/kdeunstable/libkdegames/kgamerenderer.cpp:641
#16 0x00007f7768d2ac3c in KGRInternal::Worker::run (this=0x1ba7360) at /home/kdeunstable/libkdegames/kgamerenderer.cpp:564
#17 0x00007f77680fb45d in QThreadPoolThread::run (this=0x1ba7390) at concurrent/qthreadpool.cpp:107
#18 0x00007f7768107aec in QThreadPrivate::start (arg=0x1ba7390) at thread/qthread_unix.cpp:338
#19 0x00007f776680ae9a in start_thread (arg=0x7f775b962700) at pthread_create.c:308
#20 0x00007f7766b13cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#21 0x0000000000000000 in ?? ()

The problem is caused because our KGameRenderer is a K_GLOBAL_STATIC that uses a pen that is a Q_GLOBAL_STATIC and depending on the destruction order it may happen that the QPen is destroyed first and then bad stuff happens.

I've workarounded the issue by making the KGameRenderer not be a K_GLOBAL_STATIC anymore and adding a specific cleanup() call</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;">Ran
  while [ true ]; do ./tests/enginetest; if [ $? -ne 0 ]; then break; fi done 
for a long time with no crashes</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>mainwindow.cpp <span style="color: grey">(cda3117)</span></li>

 <li>renderer.h <span style="color: grey">(a1bdae3)</span></li>

 <li>renderer.cpp <span style="color: grey">(f128c9c)</span></li>

 <li>tests/enginetest.h <span style="color: grey">(5102ea3)</span></li>

 <li>tests/enginetest.cpp <span style="color: grey">(b0c5ea4)</span></li>

</ul>

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







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








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