Bug 113517

Summary: Migration from 32 bits to 64 bits change endianess and crash kmail on indexes
Product: [Unmaintained] kmail Reporter: Helio Chissini de Castro <helio>
Component: indexAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: crash CC: des, kde
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Helio Chissini de Castro 2005-09-28 16:54:46 UTC
Version:            (using KDE KDE 3.4.90)
Installed from:    Compiled From Sources

Recent migration from a 32 bits to 64 bits machine causes kmail crash since indexes aren't clean and endianess is different
Problem detected by Till Adam.
kmail shoul autoclean indexes on such cases.
Comment 1 Josh Berry 2009-03-16 00:59:08 UTC
Here is a backtrace and log output demonstrating the problem.  (Copied from bug 182582 comment 4 and 5.)

Backtrace:

Application: KMail (kmail), signal SIGABRT
Thread 1 (Thread 0xb42fe920 (LWP 24307)):
[KCrash Handler]
#6  0xffffe424 in __kernel_vsyscall ()
#7  0xb66c9670 in raise () from /lib/libc.so.6
#8  0xb66caeb8 in abort () from /lib/libc.so.6
#9  0xb66c26ee in __assert_fail () from /lib/libc.so.6
#10 0xb75e0147 in KMMsgBase::getLongPart (this=0x904d368,
t=KMMsgBase::MsgSizePart) at /usr/src/kde4/kdepim/kmail/kmmsgbase.cpp:1035
#11 0xb759928e in KMMsgInfo::msgSize (this=0x6) at
/usr/src/kde4/kdepim/kmail/kmmsginfo.cpp:592
#12 0xb75df017 in KMMsgBase::asIndexString (this=0x904d368, length=@0xbfc69778)
at /usr/src/kde4/kdepim/kmail/kmmsgbase.cpp:1160
#13 0xb75df9e1 in KMMsgBase::syncIndexString (this=0x904d368) at
/usr/src/kde4/kdepim/kmail/kmmsgbase.cpp:1196
#14 0xb770bc8c in KMFolderIndex::updateIndex (this=0x86ffac0,
aboutToClose=true) at /usr/src/kde4/kdepim/kmail/kmfolderindex.cpp:57
#15 0xb7608dec in KMFolderMbox::reallyDoClose (this=0x86ffac0) at
/usr/src/kde4/kdepim/kmail/kmfoldermbox.cpp:289
#16 0xb7619473 in KMFolderImap::reallyDoClose (this=0x86ffac0) at
/usr/src/kde4/kdepim/kmail/kmfolderimap.cpp:131
#17 0xb758550d in FolderStorage::close (this=0x6, aForced=243) at
/usr/src/kde4/kdepim/kmail/folderstorage.cpp:110
#18 0xb7563322 in KMFolder::close (this=0x86feed0, owner=0xb79142ab
"MessageListView::StorageModel", force=<value optimized out>) at
/usr/src/kde4/kdepim/kmail/kmfolder.cpp:542
#19 0xb77fa767 in ~StorageModel (this=0x8edd968) at
/usr/src/kde4/kdepim/kmail/messagelistview/storagemodel.cpp:186
#20 0xb784d664 in KMail::MessageListView::Core::Widget::setStorageModel
(this=0x83eed48, storageModel=0x0,
preSelectionMode=KMail::MessageListView::Core::PreSelectNone)
    at /usr/src/kde4/kdepim/kmail/messagelistview/core/widgetbase.cpp:315
#21 0xb77ff749 in KMail::MessageListView::Widget::setFolder (this=0x83eed48,
fld=0x0, icon=@0xbfc69a38,
preSelectionMode=KMail::MessageListView::Core::PreSelectNone)
    at /usr/src/kde4/kdepim/kmail/messagelistview/widget.cpp:113
#22 0xb77f779e in KMail::MessageListView::Pane::setCurrentFolder
(this=0x84f77d0, fld=0x0, preferEmptyTab=false,
preSelectionMode=KMail::MessageListView::Core::PreSelectNone, 
    overrideLabel=@0xbfc69a84) at
/usr/src/kde4/kdepim/kmail/messagelistview/pane.cpp:204
#23 0xb76fb6eb in KMMainWidget::folderSelected (this=0x83ea320,
aFolder=0x85f75f0, forceJumpToUnread=false, preferNewTabForOpening=<value
optimized out>)
    at /usr/src/kde4/kdepim/kmail/kmmainwidget.cpp:3021
#24 0xb76fb84f in KMMainWidget::slotFolderViewManagerFolderActivated
(this=0x83ea320, fld=0x85f75f0, middleClick=<value optimized out>) at
/usr/src/kde4/kdepim/kmail/kmmainwidget.cpp:2884
#25 0xb7706669 in KMMainWidget::qt_metacall (this=0x83ea320,
_c=QMetaObject::InvokeMetaMethod, _id=161, _a=0xbfc69bb8) at
/usr/src/kde4/build/kdepim/kmail/kmmainwidget.moc:509
#26 0xb723d2f1 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4
#27 0xb723d8a3 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4
#28 0xb751965a in KMail::FolderViewManager::folderActivated (this=0x875d168,
_t1=0x85f75f0, _t2=false) at /usr/src/kde4/build/kdepim/kmail/folderview.moc:89
#29 0xb751bf1e in KMail::FolderViewManager::viewFolderActivated
(this=0x875d168, view=0x88fa760, fld=0x85f75f0, middleButton=<value optimized
out>) at /usr/src/kde4/kdepim/kmail/folderview.cpp:149
#30 0xb7520af6 in KMail::FolderView::activateItemInternal (this=0x88fa760,
fvi=0x8aee640, keepSelection=false, notifyManager=true, middleButton=<value
optimized out>)
    at /usr/src/kde4/kdepim/kmail/folderview.cpp:999
#31 0xb7519273 in KMail::FolderView::activateItem (this=0x88fa760,
fvi=0x8aee640, keepSelection=<value optimized out>, middleButton=<value
optimized out>)
    at /usr/src/kde4/kdepim/kmail/folderview.cpp:976
#32 0xb751c661 in KMail::FolderView::slotItemClicked (this=0x88fa760,
item=0x8aee648, column=0) at /usr/src/kde4/kdepim/kmail/folderview.cpp:529
#33 0xb7523b88 in KMail::FolderView::qt_metacall (this=0x88fa760,
_c=QMetaObject::InvokeMetaMethod, _id=13, _a=0xbfc69db8) at
/usr/src/kde4/build/kdepim/kmail/folderview.moc:204
#34 0xb7529043 in KMail::MainFolderView::qt_metacall (this=0x88fa760,
_c=QMetaObject::InvokeMetaMethod, _id=139, _a=0xbfc69db8) at
/usr/src/kde4/build/kdepim/kmail/mainfolderview.moc:64
#35 0xb723d2f1 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4
#36 0xb723d8a3 in QMetaObject::activate () from /usr/lib/qt4/libQtCore.so.4
#37 0xb6f7018a in QTreeWidget::itemClicked () from /usr/lib/qt4/libQtGui.so.4
#38 0xb6f73ea5 in ?? () from /usr/lib/qt4/libQtGui.so.4
#39 0x088fa760 in ?? ()
#40 0x08aee648 in ?? ()
#41 0x00000000 in ?? ()

Log messages:

kmail(25014) KMFolderIndex::updateIndexStreamPtr: utime(
"/home/des/.kde4/share/apps/kmail/imap/.2000640747.directory/.INBOX.directory/.backup.index.ids"
, 0) failed (KMMsgDict::getFolderIdsLocation( *this )) 
kmail(25014) KMFolderIndex::readIndexHeader: Index File sizeOfLong is 8  while
sizeof(long) is 4  !
kmail: /usr/src/kde4/kdepim/kmail/kmmsgbase.cpp:1048: off_t
KMMsgBase::getLongPart(KMMsgBase::MsgPartType) const: Assertion `sizeOfLong ==
len' failed.
Comment 2 Thomas McGuire 2009-03-16 13:52:35 UTC
I'm aware of some 32/64 bit trouble, but I only have a 32 bit PC to test.
I know for example that on 64 bit, the index sometimes gets corrupted, but no way to test this.
Comment 3 Nicolas L. 2010-09-01 13:11:52 UTC
can't we just recreate the index ?
with something like :

Index: kmail/kmmsgbase.cpp
===================================================================
--- kmail/kmmsgbase.cpp (révision 1164609)
+++ kmail/kmmsgbase.cpp (copie de travail)
@@ -1060,7 +1060,12 @@
       goto retry;
     }
     if(type == t) {
-      assert(sizeOfLong == len);
+      if (sizeOfLong == len)
+      {
+        if (!storage()->recreateIndex())
+          return 0;
+        goto retry;
+      }
       if (sizeOfLong == sizeof(ret))
       {
         copy_from_stream(ret);
Comment 4 Myriam Schweingruber 2012-08-19 11:02:06 UTC
Thank you for your report. Kmail1 is currently unmaintained and the code has changed sufficiently in Kmail2 so the backtraces are not really useful anymore. Should you experience the same crash in Kmail 4.8.5 or later, please open a new report for Kmail2. Thank you for your understanding