Bug 88508 - kmail crashes when expiring mail
Summary: kmail crashes when expiring mail
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: 1.7
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-31 09:54 UTC by Dirk Heinrichs
Modified: 2007-09-14 12:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Backtrace of the crash (5.10 KB, text/plain)
2004-09-10 09:49 UTC, Dirk Heinrichs
Details
New backtrace, now with debug information (2.41 KB, text/plain)
2004-09-14 08:36 UTC, Dirk Heinrichs
Details
Another backtrace, from expiring a single folder (3.60 KB, text/plain)
2004-09-14 08:48 UTC, Dirk Heinrichs
Details
Log containing job scheduler output (5.02 KB, text/plain)
2004-09-14 14:00 UTC, Dirk Heinrichs
Details
jobscheduler.diff (3.16 KB, text/x-diff)
2004-09-14 17:14 UTC, David Faure
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Heinrichs 2004-08-31 09:54:51 UTC
Version:           1.7 (using KDE 3.3.0, Gentoo)
Compiler:          gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)
OS:                Linux (i686) release 2.6.7

Kmail often crashes when I expire mails via menu. It seems I have to type some more words here just to make bugzilla happy. There not much more to write: I select expire, kmail crashes.
Comment 1 Carsten Burghardt 2004-08-31 10:38:53 UTC
What type of account is this? Is it reproducable?
Please compile kmail with --enable-debug=full and post the backtrace.

Comment 2 Dirk Heinrichs 2004-08-31 10:53:17 UTC
This is a local (mbox) account. Yes, it is reproducible, but not allways.

Will start recompiling kdepim today... Stay tuned.
Comment 3 Dirk Heinrichs 2004-09-07 08:41:16 UTC
Quick update: Recompiled with debugging symbols, and had the crash (segfault, btw.) a couple fo minutes ago, but wasn't aware I need gdb installed to get a backtrace. Let's see when it will happen again.

One clarification: While the account is an mbox one (mails are taken from ~/mbox), everything else is maildir.
Comment 4 David Faure 2004-09-08 15:45:31 UTC
Given that Expire is available in the RMB popupmenu for a folder, can you try
to find out which folder crashes when being expired?
Then the question will be whether that folder is mbox or maildir, and whether
I can have a copy of it :) Or a backtrace, of course.

Comment 5 Dirk Heinrichs 2004-09-10 09:49:41 UTC
Created attachment 7478 [details]
Backtrace of the crash
Comment 6 Dirk Heinrichs 2004-09-10 09:54:24 UTC
Expiring folder by folder did not result in the crash. And the expired folders are all maildir. I have attached a trace now, but I'm afraid that Gentoo stripped the symbols regardless of the "debug" USE flag. If this is not sufficient I'll try to rebuild again and prohibit stripping.
Comment 7 David Faure 2004-09-10 20:18:02 UTC
On Friday 10 September 2004 09:54, Dirk Heinrichs wrote:
> Expiring folder by folder did not result in the crash. And the expired folders are all maildir. 
> I have attached a trace now, but I'm afraid that Gentoo stripped the symbols regardless of the "debug" USE flag.
> If this is not sufficient I'll try to rebuild again and prohibit stripping.  

Any debug output from just before the crash?

This is KDE-3.3.0-final, right? (kmfolder.cpp r1.338 if you have the release tarball)

If you can recompile to get debug symbols (-g3) in kmail, can you also uncomment
#define DEBUG_SCHEDULER
at the top of jobscheduler.h?
This will make the debug output more complete, for the job scheduling stuff (which
is where the crash happens).

Comment 8 Dirk Heinrichs 2004-09-14 08:36:26 UTC
Created attachment 7519 [details]
New backtrace, now with debug information

OK, I recompiled now, preventing Gentoo portage from stripping the symbols. I
also modified jobscheduler.h.

The first thing that changed is that the crash is now 100% reproducible (if
"Expire old Mails from all folders" is selected from the main menu). The other
thing is that the backtrace got even shorter, didn't expect that.
Comment 9 Dirk Heinrichs 2004-09-14 08:48:15 UTC
Created attachment 7520 [details]
Another backtrace, from expiring a single folder

I now also managed to get the crash by expiring a single folder (had to try
several times, though).
Comment 10 David Faure 2004-09-14 13:33:21 UTC
> OK, I recompiled now, preventing Gentoo portage from stripping the symbols. I
> also modified jobscheduler.h.

Thanks for the backtraces. Since you enabled the debug output in jobscheduler.h,
can you send me that debug output? Either run kmail from a terminal with
kmail 2>&1 | tee log
and send me the log file,
or check ~/.xsession-errors for the logs of a kmail started by KDE
(the first way is simpler in your case, since the bug is reproduceable)

Comment 11 Dirk Heinrichs 2004-09-14 14:00:42 UTC
Created attachment 7523 [details]
Log containing job scheduler output

Here it comes.
Comment 12 David Faure 2004-09-14 17:14:54 UTC
Yay, I found where the bug is.
In this particular situation a task gets run and deleted but not removed from list.
Attached patch should fix the crash.



Created an attachment (id=7525)
jobscheduler.diff
Comment 13 David Faure 2004-09-14 17:17:21 UTC
CVS commit by faure: 

Fix crash when expiring mail with the menu item
CCMAIL: 88508-done@bugs.kde.org


  M +12 -8     jobscheduler.cpp   1.7.2.1
  M +2 -1      jobscheduler.h   1.6.2.1


--- kdepim/kmail/jobscheduler.cpp  #1.7:1.7.2.1
@@ -62,5 +62,5 @@ void JobScheduler::registerTask( Schedul
     KMFolder* folder = task->folder();
     // Search for an identical task already scheduled
-    for( QValueList<ScheduledTask *>::ConstIterator it = mTaskList.begin(); it != mTaskList.end(); ++it ) {
+    for( QValueList<ScheduledTask *>::Iterator it = mTaskList.begin(); it != mTaskList.end(); ++it ) {
       if ( (*it)->taskTypeId() == typeId && (*it)->folder() == folder ) {
 #ifdef DEBUG_SCHEDULER
@@ -70,4 +70,5 @@ void JobScheduler::registerTask( Schedul
         if ( !mCurrentTask && immediate ) {
           ScheduledTask* task = *it;
+          removeTask( it );
           runTaskNow( task );
         }
@@ -92,4 +93,11 @@ void JobScheduler::registerTask( Schedul
 }
 
+void JobScheduler::removeTask( TaskList::Iterator& it )
+{
+  if ( (*it)->isImmediate() )
+    --mPendingImmediateTasks;
+  mTaskList.remove( it );
+}
+
 void JobScheduler::notifyOpeningFolder( KMFolder* folder )
 {
@@ -130,5 +138,5 @@ void JobScheduler::slotRunNextJob()
     ScheduledTask* task = 0;
     // Find a task suitable for being run
-    for( QValueList<ScheduledTask *>::Iterator it = mTaskList.begin(); it != mTaskList.end(); ++it ) {
+    for( TaskList::Iterator it = mTaskList.begin(); it != mTaskList.end(); ++it ) {
       // Remove if folder died
       KMFolder* folder = (*it)->folder();
@@ -137,7 +145,5 @@ void JobScheduler::slotRunNextJob()
         kdDebug(5006) << "   folder for task " << (*it) << " was deleted" << endl;
 #endif
-        if ( (*it)->isImmediate() )
-          --mPendingImmediateTasks;
-        mTaskList.remove( it );
+        removeTask( it );
         if ( !mTaskList.isEmpty() )
           slotRunNextJob(); // to avoid the mess with invalid iterators :)
@@ -156,7 +162,5 @@ void JobScheduler::slotRunNextJob()
       if ( !folder->isOpened() ) {
         task = *it;
-        mTaskList.remove( it );
-        if ( task->isImmediate() )
-          --mPendingImmediateTasks;
+        removeTask( it );
         break;
       }

--- kdepim/kmail/jobscheduler.h  #1.6:1.6.2.1
@@ -120,6 +120,7 @@ private:
   void interruptCurrentTask();
   void runTaskNow( ScheduledTask* task );
-private:
   typedef QValueList<ScheduledTask *> TaskList;
+  void removeTask( TaskList::Iterator& it );
+private:
   TaskList mTaskList; // FIFO of tasks to be run