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





 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Actually ... I think the problem here is in clang, not JS. The JS locking code is inefficient, but not wrong. Calling BackgroundParser::isQueued() or so with the DUChainLock held should be allowed.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">What really causes the deadlocks (https://bugs.kde.org/show_bug.cgi?id=367825, http://blog.svenbrauch.de/2016/06/16/kdevelop-5-0-standalone-executable-for-linux/#comment-529) is that Clang's parsejob constructor acquires a DUChain lock (in translationUnitForURL()). That must not happen, because createParseJob is called from BackgroundParser::parseDocuments(), and that holds the background parser mutex. So clang first acquires the background parser mutex, then the duchain lock; and JS first acquires the duchain lock and then the background parser mutex (by calling isQueued() with the duchain lock held) -> deadlock. The second lock ordering (used by JS and other languages) is far more sensible, because the background parser mutex is needed for much shorter times much less frequently.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I'll see that I can fix that in clang.</p></pre>
 <br />









<p>- Sven Brauch</p>


<br />
<p>On September 1st, 2016, 8:22 p.m. UTC, Sven Brauch wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDevelop and Kevin Funk.</div>
<div>By Sven Brauch.</div>


<p style="color: grey;"><i>Updated Sept. 1, 2016, 8:22 p.m.</i></p>







<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=367825">367825</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdevelop
</div>


<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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">We <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">must not</em> hold a duchain lock when contextOfFile() is called. That
might try to add something to the background parser queue, which locks
the background parser mutex; then both locks are held, which causes
deadlocks.</p></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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Opened some test project, no crashes, no freezes, and the (I think) reason for the freeze is gone.</p></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>languages/qmljs/codecompletion/context.cpp <span style="color: grey">(3a44f45)</span></li>

 <li>languages/qmljs/codecompletion/tests/test_qmljscompletion.cpp <span style="color: grey">(b689418)</span></li>

 <li>languages/qmljs/duchain/declarationbuilder.cpp <span style="color: grey">(fb0cb5d)</span></li>

 <li>languages/qmljs/duchain/expressionvisitor.cpp <span style="color: grey">(3b641f5)</span></li>

 <li>languages/qmljs/duchain/frameworks/nodejs.cpp <span style="color: grey">(41964e4)</span></li>

 <li>languages/qmljs/duchain/helper.cpp <span style="color: grey">(e537103)</span></li>

 <li>languages/qmljs/duchain/parsesession.cpp <span style="color: grey">(d1ad4a9)</span></li>

</ul>

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






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







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