Bug 143869

Summary: crash with new copy folder function
Product: [Applications] kmail Reporter: m.wege
Component: disconnected IMAPAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 1.9.6   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: message that seems to have caused the crash

Description m.wege 2007-04-05 11:37:42 UTC
Version:           1.9.6 (using KDE 3.5.6 "release 64.1" , openSUSE )
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.18.8-ccj45-default

I just tried out the new copy folder function. A really nice thing by the way since I have to migrate about 1,5 GB of Mails in more than 100 folders to another account. Unfortunatly it crashed during the copying.

This is the backtrace:

Using host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -1249150512 (LWP 4208)]
[New Thread -1280775280 (LWP 4510)]
[New Thread -1272382576 (LWP 4509)]
[New Thread -1263989872 (LWP 4508)]
[New Thread -1255597168 (LWP 4507)]
[KCrash handler]
#9  0xb7b3418a in KMMessage::asDwMessage ()
   from /opt/kde3/lib/libkmailprivate.so
#10 0xb7d65206 in KMCopyCommand::execute ()
   from /opt/kde3/lib/libkmailprivate.so
#11 0xb7d57399 in KMCommand::slotPostTransfer ()
   from /opt/kde3/lib/libkmailprivate.so
#12 0xb7d5f226 in KMCommand::qt_invoke () from /opt/kde3/lib/libkmailprivate.so
#13 0xb7d5f50b in KMMenuCommand::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so
#14 0xb7d5f666 in KMCopyCommand::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so
#15 0xb72d7fcd in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#16 0xb7d55fee in KMCommand::messagesTransfered ()
   from /opt/kde3/lib/libkmailprivate.so
#17 0xb7d5e581 in KMCommand::transferSelectedMsgs ()
   from /opt/kde3/lib/libkmailprivate.so
#18 0xb7d5e6e7 in KMCommand::slotStart () from /opt/kde3/lib/libkmailprivate.so
#19 0xb7d5f238 in KMCommand::qt_invoke () from /opt/kde3/lib/libkmailprivate.so
#20 0xb7d5f50b in KMMenuCommand::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so
#21 0xb7d5f666 in KMCopyCommand::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so
#22 0xb72d7fcd in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#23 0xb76130ce in QSignal::signal () from /usr/lib/qt3/lib/libqt-mt.so.3
#24 0xb72f40a7 in QSignal::activate () from /usr/lib/qt3/lib/libqt-mt.so.3
#25 0xb72fb433 in QSingleShotTimer::event ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#26 0xb7278a77 in QApplication::internalNotify ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#27 0xb7279841 in QApplication::notify () from /usr/lib/qt3/lib/libqt-mt.so.3
#28 0xb7937743 in KApplication::notify () from /opt/kde3/lib/libkdecore.so.4
#29 0xb726dc83 in QEventLoop::activateTimers ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#30 0xb7227cf0 in QEventLoop::processEvents ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#31 0xb728f8a0 in QEventLoop::enterLoop () from /usr/lib/qt3/lib/libqt-mt.so.3
#32 0xb728f736 in QEventLoop::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
#33 0xb727862f in QApplication::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
#34 0x0804a0fb in main ()

And BTW: At least if you are move greater amounts of Folders it would be good to have a kind of progress visualisation and the possibility to cancel resume the process. Even cooler would be if it would be possible to have this running in the background so that one can continue working.
Comment 1 m.wege 2007-05-22 16:02:05 UTC
Same crash exists in KDE 3.5.7 on kubuntu
Comment 2 Thomas McGuire 2007-05-22 16:08:06 UTC
Can you pinpoint the message which produces the problem?
My guess is that this is a message with a big attachment. Please check that.
Comment 3 m.wege 2007-05-22 16:35:42 UTC
I am not quite sure how to do this. It is a large folder with subfolders. Will it be the last message in the last folder? Or is there a logfile, where I can find out?
Comment 4 m.wege 2007-05-22 16:40:21 UTC
It seems like it crashed after creating a subfolder or when reading/writing  the first message. I can export that folder, since it only contains a mailing list
Comment 5 Thomas McGuire 2007-05-22 16:49:33 UTC
A mailinglist is probably to big as an attachment for bugzilla.
Please try to narrow down the problem a litte more:

Manually create a folder and copy some messages of your mailinglist folder to there.
Then try to copy your new folder to somewhere else. 
-If it doesn't crash, add some messages from the original folder to the mailinglist folder and try again. 
-If it does crash, remove as many messages from that folder as possible until it does not crash anymore

This way, it should be possible to know which message causes the crash or if even copying empty folders crashes.

If it does not crash at all with this method, it is probably related to subfolders. Try to manually recreate the folder structure, with one message only in each folder, and try to copy the root folder of your manually created folder structure.

I hope I could explain what I mean and I hope you track the problem down.

In the end, if this problem is not related to a special message, I need a report like:
Create folder A, with subfolder B and C. Put a message in folder B only and try to copy folder A to somewhere. It will crash then.
Comment 6 m.wege 2007-05-22 17:05:29 UTC
ok, I think I have isolated the message. After removing it, there is no crash. I also noticed there is no crash when copying vom DIMAP to local folder. The  crash only happens when copying from DIMAP to DIMAP.
There is another suspicious message, one of the empty ones cause by the famous DIMAP-crashing bug. But after deleting the crash still appeared. Just to be sure, here is the content of that empty mail.

X-UID: 8
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  
Comment 7 m.wege 2007-05-22 17:06:14 UTC
Created attachment 20670 [details]
message that seems to have caused the crash
Comment 8 m.wege 2007-05-22 21:42:38 UTC
Without this stopper message the copy function ran for a while without crashing. But it seems to take a lot of system resources (my message base is 1,2GB) and finally froze the first of Kmail, then the whole KDE, it took a very long time to get a console. After nearly an hour I restarted X because it was unknown to me if the copy procedure was still going on.
Comment 9 Thomas McGuire 2007-05-22 21:48:55 UTC
Copying messages is a blocking function, and with 1.2GB it indeed takes long.
However, it shouldn't hang X or KDE. Maybe this was what I mentioned earlier: A message with a big attachment taking all memory, thus slowing down the system.

I have no DIMAP, so I can't reproduce unfortunately. I'll tell the original author though.
Comment 10 Volker Krause 2007-07-17 12:28:33 UTC
SVN commit 688956 by vkrause:

Don't crash when copying/moving a folder with a corrupt IMAP cache.
CCBUG: 143869


 M  +7 -0      kmcommands.cpp  


--- branches/kdepim/enterprise/kdepim/kmail/kmcommands.cpp #688955:688956
@@ -1950,6 +1950,13 @@
       idx = srcFolder->find(msgBase);
       assert(idx != -1);
       msg = srcFolder->getMsg(idx);
+      // corrupt IMAP cache, see FolderStorage::getMsg()
+      if ( msg == 0 ) {
+        KMessageBox::error( parentWidget(), i18n("Corrupt IMAP cache detected in folder %1. "
+            "Copying of messages aborted.").arg( srcFolder->prettyURL() ) );
+        deleteLater();
+        return Failed;
+      }
     }
 
     if (srcFolder && mDestFolder &&
Comment 11 Thomas McGuire 2007-07-17 15:49:46 UTC
>Don't crash when copying/moving a folder with a corrupt IMAP cache. 
>CCBUG: 143869 
Volker: Why only CCBUG and not BUG? Was this not completely fixed?
Comment 12 Volker Krause 2007-07-18 14:33:21 UTC
SVN commit 689500 by vkrause:

Backport commits 688956 and 689037 from enterprise branch (crash
fixes for folder moving).

I'm aware that this breaks the message freeze, but an untranslated error
message seems to be a better option than a potentially dangerous crash.

BUG: 143869


 M  +7 -0      kmcommands.cpp  
 M  +6 -0      kmfoldertree.cpp  


--- branches/KDE/3.5/kdepim/kmail/kmcommands.cpp #689499:689500
@@ -1935,6 +1935,13 @@
       idx = srcFolder->find(msgBase);
       assert(idx != -1);
       msg = srcFolder->getMsg(idx);
+      // corrupt IMAP cache, see FolderStorage::getMsg()
+      if ( msg == 0 ) {
+        KMessageBox::error( parentWidget(), i18n("Corrupt IMAP cache detected in folder %1. "
+            "Copying of messages aborted.").arg( srcFolder->prettyURL() ) );
+        deleteLater();
+        return Failed;
+      }
     }
 
     if (srcFolder && mDestFolder &&
--- branches/KDE/3.5/kdepim/kmail/kmfoldertree.cpp #689499:689500
@@ -2031,6 +2031,12 @@
     }
   }
 
+  // de-select moved source folders (can cause crash due to unGetMsg() in KMHeaders)
+  if ( move ) {
+    doFolderSelected( indexOfFolder( destination ), false );
+    oldCurrent = currentItem();
+  }
+
   // do the actual move/copy
   for ( QValueList<QGuardedPtr<KMFolder> >::ConstIterator it = sources.constBegin(); it != sources.constEnd(); ++it ) {
     KMFolder* source = *it;
Comment 13 m.wege 2007-11-04 08:42:53 UTC
I have now KDE 3.58 running and tried to use the copy function again. It now crashes with a different mail (without any backtrace, kmail just disappears). I send the mail to someone privateately for testing, where it stopped). One characteristic of the mail is that it is big (36MB), so there may be a memory problem. It also seem that the longer the copy function is running, it is becoming slower.
Comment 14 Thomas McGuire 2007-11-04 18:09:33 UTC
>One characteristic of the mail is that it is big (36MB), so there may be a memory problem. It also seem that the longer the copy function is running, it is becoming slower. 
This is not a problem specific to the copy function, KMail generally has problems with big messages, see bug 110574.
Closing this bug report again, see the other one.