Bug 70406 - kmail crash on startup in KMFolderMgr::readMsgDict
Summary: kmail crash on startup in KMFolderMgr::readMsgDict
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 82456 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-12-14 16:19 UTC by Martin Koller
Modified: 2007-09-14 12:17 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Koller 2003-12-14 16:19:35 UTC
Version:           unknown (using KDE 3.1.94 (CVS >= 20031206), compiled sources)
Compiler:          gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)
OS:          Linux (i686) release 2.4.22

I have updated kdepim about 1 hour ago, installed and restarted KDE, now on login/startup of kmail I have the following crash:

[New Thread 1024 (LWP 9903)]
0x41f29219 in __wait4 () from /lib/i686/libc.so.6
#0  0x41f29219 in __wait4 () from /lib/i686/libc.so.6
#1  0x41f291a9 in __libc_waitpid (pid=9912, stat_loc=0x0, options=0)
    at ../sysdeps/unix/sysv/linux/waitpid.c:26
#2  0x41dd16d3 in waitpid (pid=9912, stat_loc=0x0, options=0)
    at wrapsyscall.c:172
#3  0x412f29e0 in KCrash::defaultCrashHandler (sig=11) at kcrash.cpp:246
#4  0x41dcfa65 in pthread_sighandler (signo=11, ctx=
      {gs = 7, __gsh = 0, fs = 0, __fsh = 0, es = 43, __esh = 0, ds = 43, __dsh = 0, edi = 1296769059, esi = 1, ebp = 3221219912, esp = 3221219808, ebx = 1077297344, edx = 138960768, ecx = 139413136, eax = 0, trapno = 14, err = 6, eip = 1075644942, cs = 35, __csh = 0, eflags = 66199, esp_at_signal = 3221219808, ss = 43, __ssh = 0, fpstate = 0xbfffe760, oldmask = 2147483648, cr2 = 0})
    at signals.c:97
#5  <signal handler called>
#6  KMMsgDict::readFolderIds (this=0x8484440, folder=0x825dab0)
    at /opt/qt3/include/qmemarray.h:102
#7  0x401f881c in KMFolderMgr::readMsgDict (this=0x8226300, dict=0x8484440, 
    dir=0x825ee30, pass=1) at kmfoldermgr.cpp:453
#8  0x401f8863 in KMFolderMgr::readMsgDict (this=0x8226300, dict=0x8484440, 
    dir=0x823e930, pass=1) at kmfoldermgr.cpp:453
#9  0x401f8863 in KMFolderMgr::readMsgDict (this=0x8226300, dict=0x8484440, 
    dir=0x822632c, pass=1) at kmfoldermgr.cpp:453
#10 0x40274d84 in KMKernel::msgDict (this=0xbffff7f0) at kmkernel.h:157
#11 0x40187e61 in KMHeaders::readSortOrder (this=0x82b3848, set_selection=true)
    at kmkernel.h:118
#12 0x40183bc2 in KMHeaders::updateMessageList (this=0x82b3848, 
    set_selection=true) at kmheaders.cpp:2255
#13 0x4017e867 in KMHeaders::setFolder (this=0x82b3848, aFolder=0x8238490, 
    jumpToFirst=true) at kmheaders.cpp:994
#14 0x402cfb74 in KMMainWidget::folderSelected (this=0x82b18d0, 
    aFolder=0x8238490, jumpToUnread=false) at kmmainwidget.cpp:1571
#15 0x402cf8ae in KMMainWidget::folderSelected (this=0x82b18d0, 
    aFolder=0x8238490) at kmmainwidget.cpp:1511
#16 0x402c89f8 in KMMainWidget::qt_invoke (this=0x82b18d0, _id=50, 
    _o=0xbffff230) at /opt/qt3/include/private/qucom_p.h:312
#17 0x417075e7 in QObject::activate_signal (this=0x82fe398, clist=0x82c4238, 
    o=0xbffff230) at kernel/qobject.cpp:2333
#18 0x4017132f in KMFolderTree::folderSelected (this=0x82fe398, t0=0x8238490)
    at kmfoldertree.moc:352
#19 0x4016d6e0 in KMFolderTree::doFolderSelected (this=0x82fe398, 
    qlvi=0x844d3f8) at kmfoldertree.cpp:898
#20 0x402d97b4 in KMMainWidget::slotShowStartupFolder (this=0x82b18d0)
    at kmmainwidget.cpp:3008
#21 0x402c91e9 in KMMainWidget::qt_invoke (this=0x82b18d0, _id=151, 
    _o=0xbffff3a0) at kmmainwidget.moc:550
#22 0x417075e7 in QObject::activate_signal (this=0x83e0328, clist=0x83dff10, 
    o=0xbffff3a0) at kernel/qobject.cpp:2333
#23 0x41a3c866 in QSignal::signal (this=0x83e0328, t0=@0x83e0350)
    at .moc/debug-shared-mt/moc_qsignal.cpp:100
#24 0x417231ba in QSignal::activate (this=0x83e0328) at kernel/qsignal.cpp:204
#25 0x4172990e in QSingleShotTimer::event (this=0x83e0300)
    at kernel/qtimer.cpp:277
#26 0x416a7902 in QApplication::internalNotify (this=0xbffff8e0, 
    receiver=0x83e0300, e=0xbffff5e0) at kernel/qapplication.cpp:2582
#27 0x416a6a32 in QApplication::notify (this=0xbffff8e0, receiver=0x83e0300, 
    e=0xbffff5e0) at kernel/qapplication.cpp:2305
#28 0x412682f6 in KApplication::notify (this=0xbffff8e0, receiver=0x83e0300, 
    event=0xbffff5e0) at kapplication.cpp:509
#29 0x404dcfa2 in QApplication::sendEvent (receiver=0x83e0300, 
    event=0xbffff5e0) at /opt/qt3/include/qapplication.h:492
#30 0x41696b45 in QEventLoop::activateTimers (this=0x807d518)
    at kernel/qeventloop_unix.cpp:557
#31 0x41653036 in QEventLoop::processEvents (this=0x807d518, flags=4)
    at kernel/qeventloop_x11.cpp:346
#32 0x416bbdd5 in QEventLoop::enterLoop (this=0x807d518)
    at kernel/qeventloop.cpp:198
#33 0x416bbcf8 in QEventLoop::exec (this=0x807d518)
    at kernel/qeventloop.cpp:145
#34 0x416a7a9b in QApplication::exec (this=0xbffff8e0)
    at kernel/qapplication.cpp:2705
#35 0x0804b552 in main (argc=3, argv=0xbffffa94)
    at /opt/kde3/include/kapplication.h:191
Comment 1 Martin Koller 2003-12-14 16:41:55 UTC
When I set startupFolder=outbox (which is empty) and set checkmail-startup=false in kmailrc, kmail at least starts.
But if I then klick on the inbox (which contains messages), kmail crashes again.

Comment 2 Martin Koller 2003-12-14 17:06:58 UTC
I have now removed all *.index files and now I can start and use kmail again.
Comment 3 Ingo Klöcker 2003-12-14 18:34:35 UTC
Please tell us what line 102 in /opt/qt3/include/qmemarray.h is.
Comment 4 Martin Koller 2003-12-14 18:39:19 UTC
Subject: Re:  kmail crash on startup in KMFolderMgr::readMsgDict

On Sunday 14 December 2003 18:34, you wrote:
> /opt/qt3/include/qmemarray.h

    type& at( uint i ) const
Line 102==>	{ return (type &)(*(type *)QGArray::at(i*sizeof(type))); }

I use Qt-3.2.3

Comment 5 Ingo Klöcker 2004-01-20 15:30:05 UTC
After upgrading to KDE 3.2 my KMail at work crashes as well on startup. :-(

Last debug messages:

kmail: KMFolderDir creating new CachedImap folder with name Kolab@ares
kmail: KMFolderDir creating new CachedImap folder with name INBOX
kmail: KMFolderDir creating new CachedImap folder with name Calendar
kmail: KMFolderDir creating new CachedImap folder with name Contacts
kmail: KMFolderDir creating new CachedImap folder with name Notes
kmail: KMFolderDir creating new CachedImap folder with name Tasks
kmail: pPopFilter set
DCOP aborting (delayed) call from 'anonymous-17659' to 'kmail'
DCOP: unregister 'kmail'
ERROR: Communication problem with kmail, it probably crashed.


Backtrace:

[New Thread 16384 (LWP 17660)]
0x4209fa86 in waitpid () from /lib/i686/libpthread.so.0
#0  0x4209fa86 in waitpid () from /lib/i686/libpthread.so.0
#1  0x41553a33 in KCrash::defaultCrashHandler(int) (sig=11)
    at /localhome/ingo/cvs/kde/3.2/kdelibs/kdecore/kcrash.cpp:246
#2  0x4209e96c in __pthread_sighandler () from /lib/i686/libpthread.so.0
#3  <signal handler called>
#4  0x41c2f19d in QGListIterator::QGListIterator(QGList const&) ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#5  0x402267f9 in QPtrListIterator (this=0xbfffecc0, l=@0x824d000)
    at qptrlist.h:157
#6  0x4026a4fd in KMFolderMgr::readMsgDict(KMMsgDict*, KMFolderDir*, int) (
    this=0x8247318, dict=0x82c05a0, dir=0x824cfc8, pass=1)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:453
#7  0x4026a5c8 in KMFolderMgr::readMsgDict(KMMsgDict*, KMFolderDir*, int) (
    this=0x8247318, dict=0x82c05a0, dir=0x82496d8, pass=1)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:453
#8  0x4026a5c8 in KMFolderMgr::readMsgDict(KMMsgDict*, KMFolderDir*, int) (
    this=0x8247318, dict=0x82c05a0, dir=0x8275818, pass=1)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:453
#9  0x4026a5c8 in KMFolderMgr::readMsgDict(KMMsgDict*, KMFolderDir*, int) (
    this=0x8247318, dict=0x82c05a0, dir=0x8247344, pass=1)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:453
#10 0x402e7409 in KMKernel::msgDict() (this=0xbffff390)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmkernel.cpp:1639
#11 0x4029dc14 in KMMsgList::clear(bool, bool) (this=0x8247fc8, doDelete=true, 
    syncDict=true) at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmmsglist.cpp:36
#12 0x40363fe6 in KMFolderIndex::clearIndex(bool, bool) (this=0x8247f00, 
    autoDelete=true, syncDict=true)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfolderindex.cpp:430
#13 0x40223ad6 in KMFolder::remove() (this=0x8247f00)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfolder.cpp:722
#14 0x402ca2ed in KMFolderCachedImap::remove() (this=0x8247f00)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldercachedimap.cpp:153
#15 0x40269c3e in KMFolderMgr::removeFolderAux(KMFolder*) (this=0x8247318, 
    aFolder=0x8247f00)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:314
#16 0x40269d38 in KMFolderMgr::removeDirAux(KMFolderDir*) (this=0x8247318, 
    aFolderDir=0x82496d8)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:329
#17 0x40269c0b in KMFolderMgr::removeFolderAux(KMFolder*) (this=0x8247318, 
    aFolder=0x824a620)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:311
#18 0x40269d38 in KMFolderMgr::removeDirAux(KMFolderDir*) (this=0x8247318, 
    aFolderDir=0x8275818)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:329
#19 0x40269c0b in KMFolderMgr::removeFolderAux(KMFolder*) (this=0x8247318, 
    aFolder=0x82474e0)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:311
#20 0x40269ac7 in KMFolderMgr::remove(KMFolder*) (this=0x8247318, 
    aFolder=0x82474e0)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmfoldermgr.cpp:300
#21 0x402e4410 in KMKernel::cleanupImapFolders() (this=0xbffff390)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmkernel.cpp:936
#22 0x402e4001 in KMKernel::init() (this=0xbffff390)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/kmkernel.cpp:880
#23 0x0804a5b9 in main (argc=7, argv=0xbffff5f4)
    at /localhome/ingo/cvs/kde/3.2/kdepim/kmail/main.cpp:101
Comment 6 Ingo Klöcker 2004-01-20 17:00:39 UTC
After adding a debug statement KMail started without crashing. It would probably also have started without crashing if I had simply tried starting it a second time. Unfortunately I can't recreate the situation that lead to the crash.

FWIW, line 157 in qptrlist.h is
    QPtrListIterator(const QPtrList<type> &l) :QGListIterator((QGList &)l) {}
Comment 7 Till Adam 2004-05-18 09:21:01 UTC
This was temporary and is resolved now, I take it?
Comment 8 Leo Savernik 2004-07-13 09:24:33 UTC
I left KMail open when shutting down KDE (thus making it part of session management). On restarting, KMail didn't come up. Worse, it reliably crashes with the following trace:

#5  <signal handler called>
#6  0x401bac5b in KMMsgDict::readFolderIds ()
   from /opt/kde3/lib/libkmailprivate.so.0
#7  0x401dba76 in KMFolderMgr::readMsgDict ()
   from /opt/kde3/lib/libkmailprivate.so.0
#8  0x401dbac2 in KMFolderMgr::readMsgDict ()
   from /opt/kde3/lib/libkmailprivate.so.0
#9  0x40243951 in KMKernel::msgDict () from /opt/kde3/lib/libkmailprivate.so.0
#10 0x401801a9 in KMHeaders::readSortOrder ()
   from /opt/kde3/lib/libkmailprivate.so.0
#11 0x4017bf81 in KMHeaders::updateMessageList ()
   from /opt/kde3/lib/libkmailprivate.so.0
#12 0x40176efa in KMHeaders::setFolder ()
   from /opt/kde3/lib/libkmailprivate.so.0
#13 0x40294597 in KMMainWidget::folderSelected ()
   from /opt/kde3/lib/libkmailprivate.so.0
#14 0x40294219 in KMMainWidget::folderSelected ()
   from /opt/kde3/lib/libkmailprivate.so.0
#15 0x4028ce83 in KMMainWidget::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so.0
#16 0x415def37 in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#17 0x4016b4f5 in KMFolderTree::folderSelected ()
   from /opt/kde3/lib/libkmailprivate.so.0
#18 0x40167b13 in KMFolderTree::doFolderSelected ()
   from /opt/kde3/lib/libkmailprivate.so.0
#19 0x4029e4fb in KMMainWidget::slotShowStartupFolder ()
   from /opt/kde3/lib/libkmailprivate.so.0
#20 0x4028d4e9 in KMMainWidget::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so.0
#21 0x415def37 in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#22 0x4187d0f5 in QSignal::signal () from /usr/lib/qt3/lib/libqt-mt.so.3
#23 0x415f4539 in QSignal::activate () from /usr/lib/qt3/lib/libqt-mt.so.3
#24 0x415f9d90 in QSingleShotTimer::event ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#25 0x41599d64 in QApplication::internalNotify ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#26 0x415999e4 in QApplication::notify () from /usr/lib/qt3/lib/libqt-mt.so.3
#27 0x411e4a18 in KApplication::notify () from /opt/kde3/lib/libkdecore.so.4
#28 0x4158cd32 in QEventLoop::activateTimers ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#29 0x41554e82 in QEventLoop::processEvents ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#30 0x415a7fb1 in QEventLoop::enterLoop () from /usr/lib/qt3/lib/libqt-mt.so.3
#31 0x415a7ef7 in QEventLoop::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
#32 0x41599ed6 in QApplication::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
#33 0x804acb6 in KMKernel::cleanup ()
#34 0x41ca0baf in __libc_start_main () from /lib/libc.so.6

This is KDE 3.2.3 with Qt 3.3. Sorry, this is a release build.

I'm looking for a workaround.
Comment 9 Leo Savernik 2004-07-13 09:33:18 UTC
Deleting the .*.{index,ids,sorted} files of a certain subdirectory made the crash go away.

Oh no! I deleted them, so I can't reproduce the crash any more. Hope the backtrace helps somewhat.

Btw: Is KMail not intended for session management?
Comment 10 Till Adam 2004-07-18 16:29:55 UTC
*** Bug 82456 has been marked as a duplicate of this bug. ***
Comment 11 Malte S. Stretz 2004-07-18 16:36:50 UTC
Till, you marked bug 82456 as a dup of this one, but the other way round would have made more sense. Because that other bug tells you *why* this all happens and also points to a bunch of other race conditions in the code involved :)
Comment 12 Till Adam 2004-10-25 09:47:48 UTC
Raising severity so I remember to look at it soonish.
Comment 13 illogic-al 2004-12-01 11:18:13 UTC
*** Bug 63218 has been marked as a duplicate of this bug. ***
Comment 14 Till Adam 2004-12-28 18:19:01 UTC
CVS commit by tilladam: 

Be somewhat safer when reading the message serial number dict for a folder
from disk. The format is still not completely safe, but since we haven't
had any more reports of this problem it seems to have been intermittent
and there is not much more we can do. Folders can be very large, so any
kind of a maximum size would have to be so large as to be useless. If 
anyone has a patch to improve this further, send it my way.

BUG: 70406


  M +4 -3      kmfoldermgr.cpp   1.105


--- kdepim/kmail/kmfoldermgr.cpp  #1.104:1.105
@@ -510,5 +510,6 @@ void KMFolderMgr::readMsgDict(KMMsgDict 
              {
                if (pass == 1) {
-                 dict->readFolderIds(folder);
+                 if ( !dict->readFolderIds(folder) )
+                   invalidateFolder(dict, folder);
                } else if (pass == 2) {
                  if (!dict->hasFolderIds(folder)) {