<table><tr><td style="">ahmadsamir added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D23875">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D23875#529442" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D23875#529442</a>, <a href="https://phabricator.kde.org/p/dhaumann/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@dhaumann</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><p>Since this crash is in KCoreDirLister, I wonder whether we can find a unit test that reproduces this without the KFileWidget.</p></div>
</blockquote>
<p>I think the main issue here is kdirlister inserting items into pendingUpdates, then trying to use an invalid, end(), iterator in DirItem::reinsert(); so it's about the pace things happen:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">with KFileWidget, the successive creating and entering of multiple nested folders puts things in pending updates; creating the nested folders in one go a/b/c/d (which is possible), doesn't cause the crash</li>
<li class="remarkup-list-item">"Theoretically" with dolphin or gwenview, copying folders to a pen drive where presumably the latter is slow, so kdirlister is inserting items in pendingUpdates, the same with ripping an audio cd (these are slow by design it seems) and lastly copying files to a smart phone via kde-connect.</li>
</ul>
<blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D23875#529446" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D23875#529446</a>, <a href="https://phabricator.kde.org/p/dhaumann/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@dhaumann</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><p>A different patch was proposed with <a href="https://phabricator.kde.org/D21197" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D21197</a> in May 2019.</p></div>
</blockquote>
<p>I didn't know about <a href="https://phabricator.kde.org/D21197" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D21197</a>, technically it's the same patch; from the other patch, I could be wrong but:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">(*it).url() == oldUrl</pre></div>
<p>will always be true, so it's redundant.</p>
<p>A couple of stuff I found while I was stuck^Wworking on this issue, (sharing them here because better minds than mine could have a better fix):</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">It happens in slotResult() when the jobUrl is a <em>child</em> of an item dir in pendingUpdates</li>
<li class="remarkup-list-item">The parentDir in reinsert() has DirItem->lstItems.size() == 0</li>
</ul>
<p>When creating a new folder in the "save as" dialog, I see this sequence:<br />
slotFilesAdded() -> itemsAddedInDirectory() -> updateDirectory(), in the latter checkUpdate(dir) is always false.</p>
<p>Using dolphin to create a new folder, then enter it, then create a new folder inside... etc, it's the same sequence but checkUpdate(dir) is usually always true. That confirms my idea that it's about pace, things happening too fast, or too slow in the case of the pen drive / audio cd / smart phone, and kdirlister is guarding against being flooded by FAM events.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D23875">https://phabricator.kde.org/D23875</a></div></div><br /><div><strong>To: </strong>ahmadsamir, Frameworks, dfaure, chinmoyr<br /><strong>Cc: </strong>dhaumann, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>