[Kde-pim] kmail "re-populate search at startup" crash and workaround

Jason 'vanRijn' Kasper vr at movingparts.net
Wed Mar 14 16:16:03 GMT 2007


re, all.

First, my apologies if this isn't the right list...  Please let me know if I 
should subscribe/post to kmail-devel for this instead...

I hit an annoying little crash in kmail today, running current code from the 
kdepim-3.5.5+ branch.  The full bt and bottom of stdout/stderr is here:  
http://pastebin.ca/394767

The cause is the assert inside kmfoldersearch.cpp, addSerNum.  In the state 
that kmail was in, I could reproduce the crash every time I tried to start 
him up.  The problem looked to be that when a search was re-created at 
startup time, invalid results were being found, which triggered the assert.  
I changed the code locally to log the problem and return rather than causing 
an assert(), so with this I'm able to use kmail again.  And it would seem 
that it would be a more gracious thing to do to warn the user that her search 
folder couldn't be recreated rather than not allowing her to use kmail at 
all.  =;)

I'd guess the better solution would be to track down why the invalid serNum is 
being used, but it wasn't immediately obvious to me after 15 minutes of 
looking through kmail code.  I'm thinking that it might be better for kmail 
to not try to re-populate previous searches automatically at startup anyway, 
but rather to wait until the first time they're asked for, but that's more of 
a usability issue, I suppose...

Is it okay to commit this patch?  Or how should I proceed?  

TIA!!  =:)


--> svn diff
Index: kmfoldersearch.cpp
===================================================================
--- kmfoldersearch.cpp  (revision 641737)
+++ kmfoldersearch.cpp  (working copy)
@@ -433,7 +433,12 @@
     int idx = -1;
     KMFolder *aFolder = 0;
     KMMsgDict::instance()->getLocation(serNum, &aFolder, &idx);
-    assert(aFolder && (idx != -1));
+    if ( (!aFolder) || (idx == -1)) {
+       kdDebug(5006) << "addSerNum: serNum: [" << serNum
+               << "], aFolder: [" << aFolder << "], idx: [" << idx
+               << "]. invalid data. returning." << endl;
+       return;
+    }
     if(mFolders.findIndex(aFolder) == -1) {
         aFolder->open();
         // Exceptional case, for when folder has invalid ids





-- 
 -[ Jason 'vanRijn' Kasper    //  http://movingparts.net ]-
 -[ KDE PIM Developer         //  http://www.kde.org  ]-
 -[ bash fun -> :(){ :|:&};:  //  Numbers 6:22-26 ]-
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/



More information about the kde-pim mailing list