Bug 335113 - kmail crashes when searching in quick filter
Summary: kmail crashes when searching in quick filter
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: search (show other bugs)
Version: 4.13.0
Platform: Kubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-21 06:44 UTC by Simon Hausmann
Modified: 2014-07-01 06:22 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.13.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Hausmann 2014-05-21 06:44:40 UTC
In kmail's debug output I see the following:

""
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid
""

The backtrace at that point naturally doesn't give anything away. I noticed however on akonadi startup the following also:

""
akonadi_baloo_indexer(16245): Failed to create email indexer: "Error opening table `/home/shausman/.local/share/baloo/email//record.':
Couldn't open /home/shausman/.local/share/baloo/email//record.baseA: No such file or directory
Unable to read revision from /home/shausman/.local/share/baloo/email//record.baseB
""

as well as

""
Executing search "kmail2-869657646-SearchSession" 
akonadiserver(16196): Xapian Database does not exist at  "/home/shausman/.local/share/baloo/email/" 
Search done "kmail2-869657646-SearchSession" (without remote search) 
        Result: 0 matches 
""

In order to get something more useful from gdb I did a "catch throw" to find out where the exception was throw. The first throw was here, where it looks like it can't open that database:

""
Catchpoint 2 (exception thrown), 0x00007ffff5825a30 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff5825a30 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007fffe38b99a1 in ChertTable::basic_open(bool, unsigned int) () from /usr/lib/libxapian.so.22
#2  0x00007fffe38bd978 in ChertTable::do_open_to_read(bool, unsigned int) () from /usr/lib/libxapian.so.22
#3  0x00007fffe3898ce1 in ?? () from /usr/lib/libxapian.so.22
#4  0x00007fffe389d770 in ?? () from /usr/lib/libxapian.so.22
#5  0x00007fffe3843086 in Xapian::Database::Database(std::string const&) () from /usr/lib/libxapian.so.22
#6  0x00007fffea95b46b in Baloo::PIM::EmailQuery::exec() () from /usr/lib/libbaloopim.so.4
#7  0x00007ffff112a3e6 in MessageList::Core::Filter::setSearchString (this=0x1e021d0, search=..., options=...) at ../../messagelist/core/filter.cpp:122
#8  0x00007ffff116ece9 in MessageList::Core::Widget::searchTimerFired (this=0xbce250) at ../../messagelist/core/widgetbase.cpp:989
#9  0x00007ffff5c5c87a in QMetaObject::activate (sender=0x1dec6c0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x0) at kernel/qobject.cpp:3539
#10 0x00007ffff5c60a31 in QObject::event (this=0x1dec6c0, e=<optimized out>) at kernel/qobject.cpp:1156
#11 0x00007ffff6179e2c in QApplicationPrivate::notify_helper (this=this@entry=0x6c20f0, receiver=receiver@entry=0x1dec6c0, e=e@entry=0x7fffffffd6c0) at kernel/qapplication.cpp:4567
#12 0x00007ffff61804a0 in QApplication::notify (this=this@entry=0x7fffffffdce0, receiver=receiver@entry=0x1dec6c0, e=e@entry=0x7fffffffd6c0) at kernel/qapplication.cpp:4353
#13 0x00007ffff79b4baa in KApplication::notify (this=0x7fffffffdce0, receiver=0x1dec6c0, event=0x7fffffffd6c0) at ../../kdeui/kernel/kapplication.cpp:311
#14 0x00007ffff5c484dd in QCoreApplication::notifyInternal (this=0x7fffffffdce0, receiver=0x1dec6c0, event=0x7fffffffd6c0) at kernel/qcoreapplication.cpp:953
#15 0x00007ffff5c78323 in sendEvent (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#16 QTimerInfoList::activateTimers (this=0x6b9f40) at kernel/qeventdispatcher_unix.cpp:621
#17 0x00007ffff5c75629 in timerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:193
#18 idleTimerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:240
#19 0x00007fffed369e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007fffed36a048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#21 0x00007fffed36a0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#22 0x00007ffff5c757a1 in QEventDispatcherGlib::processEvents (this=0x607b20, flags=...) at kernel/qeventdispatcher_glib.cpp:434
#23 0x00007ffff621bbb6 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#24 0x00007ffff5c470af in QEventLoop::processEvents (this=this@entry=0x7fffffffd930, flags=...) at kernel/qeventloop.cpp:149
#25 0x00007ffff5c473a5 in QEventLoop::exec (this=this@entry=0x7fffffffd930, flags=...) at kernel/qeventloop.cpp:204
#26 0x00007ffff5c4cb79 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1225
#27 0x00007ffff617837c in QApplication::exec () at kernel/qapplication.cpp:3828
#28 0x0000000000402d18 in main (argc=<optimized out>, argv=<optimized out>) at ../../kmail/main.cpp:146
""

But it seems that exception was caught. However the next one wasn't caught:

""
#0  0x00007ffff5825a30 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff5877357 in std::__throw_logic_error(char const*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007ffff5882b61 in char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff5882ef8 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007fffea95dd00 in Baloo::PIM::EmailQuery::exec() () from /usr/lib/libbaloopim.so.4
#5  0x00007ffff112a3e6 in MessageList::Core::Filter::setSearchString (this=0x1e021d0, search=..., options=...) at ../../messagelist/core/filter.cpp:122
#6  0x00007ffff116ece9 in MessageList::Core::Widget::searchTimerFired (this=0xbce250) at ../../messagelist/core/widgetbase.cpp:989
#7  0x00007ffff5c5c87a in QMetaObject::activate (sender=0x1dec6c0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x0) at kernel/qobject.cpp:3539
#8  0x00007ffff5c60a31 in QObject::event (this=0x1dec6c0, e=<optimized out>) at kernel/qobject.cpp:1156
#9  0x00007ffff6179e2c in QApplicationPrivate::notify_helper (this=this@entry=0x6c20f0, receiver=receiver@entry=0x1dec6c0, e=e@entry=0x7fffffffd6c0) at kernel/qapplication.cpp:4567
#10 0x00007ffff61804a0 in QApplication::notify (this=this@entry=0x7fffffffdce0, receiver=receiver@entry=0x1dec6c0, e=e@entry=0x7fffffffd6c0) at kernel/qapplication.cpp:4353
#11 0x00007ffff79b4baa in KApplication::notify (this=0x7fffffffdce0, receiver=0x1dec6c0, event=0x7fffffffd6c0) at ../../kdeui/kernel/kapplication.cpp:311
#12 0x00007ffff5c484dd in QCoreApplication::notifyInternal (this=0x7fffffffdce0, receiver=0x1dec6c0, event=0x7fffffffd6c0) at kernel/qcoreapplication.cpp:953
#13 0x00007ffff5c78323 in sendEvent (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#14 QTimerInfoList::activateTimers (this=0x6b9f40) at kernel/qeventdispatcher_unix.cpp:621
#15 0x00007ffff5c75629 in timerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:193
#16 idleTimerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:240
#17 0x00007fffed369e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007fffed36a048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007fffed36a0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007ffff5c757a1 in QEventDispatcherGlib::processEvents (this=0x607b20, flags=...) at kernel/qeventdispatcher_glib.cpp:434
#21 0x00007ffff621bbb6 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#22 0x00007ffff5c470af in QEventLoop::processEvents (this=this@entry=0x7fffffffd930, flags=...) at kernel/qeventloop.cpp:149
#23 0x00007ffff5c473a5 in QEventLoop::exec (this=this@entry=0x7fffffffd930, flags=...) at kernel/qeventloop.cpp:204
#24 0x00007ffff5c4cb79 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1225
#25 0x00007ffff617837c in QApplication::exec () at kernel/qapplication.cpp:3828
#26 0x0000000000402d18 in main (argc=<optimized out>, argv=<optimized out>) at ../../kmail/main.cpp:146
""


Reproducible: Always

Steps to Reproduce:
1. Start kmail
2. Select a folder with emails
3. Begin typing in the quick search field
Actual Results:  
A crash is observed

Expected Results:  
I think kmail2 (or baloo) should gracefully handle the situation where the database doesn't exist and most certainly not crash.

BTW, how do I create the database? :)
Comment 1 Simon Hausmann 2014-05-21 06:48:01 UTC
BTW, contents of ~/.local/share/baloo/email:
total 118068
-rw-r--r-- 1 shausman shausman        0 May 21 08:37 flintlock
-rw-r--r-- 1 shausman shausman       28 Apr 22 15:17 iamchert
-rw-rw-r-- 1 shausman shausman        0 Apr 23 09:39 postlist.baseA
-rw-rw-r-- 1 shausman shausman        0 Apr 23 09:39 postlist.baseB
-rw-r--r-- 1 shausman shausman 53772288 Apr 23 09:39 postlist.DB
-rw-rw-r-- 1 shausman shausman        0 Apr 23 09:39 record.baseB
-rw-r--r-- 1 shausman shausman  8732672 Apr 23 09:39 record.DB
-rw-rw-r-- 1 shausman shausman        0 Apr 23 09:39 termlist.baseB
-rw-r--r-- 1 shausman shausman 58392576 Apr 23 09:39 termlist.DB
Comment 2 Laurent Montel 2014-05-21 06:59:47 UTC
Ok I think that I found pb
I will send a fix soon.
Comment 3 Laurent Montel 2014-05-21 07:03:39 UTC
finally we fixed it in 4.13.1
see:
    const QString dir = KGlobal::dirs()->localxdgdatadir() + "baloo/email/";
    Xapian::Database db;
    try {
        db = Xapian::Database(QFile::encodeName(dir).constData());
    } catch (const Xapian::DatabaseError& e) {
        kWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
        return ResultIterator();
    }

=> we catch error.
It's in baloo.
Comment 4 Simon Hausmann 2014-05-21 07:17:18 UTC
Are you sure it's fixed? It seems commit 4d34a8286295d1eef2be24959fc51249b4322ec1 in baloo introduced this, but git tag --contains=4d34a8286295d1eef2be24959fc51249b4322ec1 suggests that fix is also in 4.13.0, which I'm running. Indeed that exception is caught and I can see the output of it. But we still get a crash later (see the second throw!)
Comment 5 Laurent Montel 2014-05-21 07:57:31 UTC
This code fixed this type of crash.
I will investigate it.
I reopen it for the moment
Comment 6 Simon Hausmann 2014-05-21 08:26:38 UTC
I'm sorry, I wish I had a line number for the second throw :(

Any idea how to re-create the baloo database, btw?
Comment 7 Laurent Montel 2014-05-21 09:06:38 UTC
akonadictl stop
rm -rf .kde/share/config/baloorc

akondictl start :)
Comment 8 Simon Hausmann 2014-05-21 11:41:31 UTC
Ok, I've deleted the existing database files in the baloo/email/ folder, restarted akonadi, waited until it indexed all my huge folders and now kmail doesn't crash anymore neither. Perhaps the database was corrupt or incomplete before that?

I understand that this might be difficult to reproduce at your end, so feel free to close this bug again.
Comment 9 Laurent Montel 2014-06-19 07:12:00 UTC
I caught some other exceptions in baloo when we create database or access to it
I hope that it fixes your crash (but I can't reproduce).

It's in 4.13.3
Comment 10 Laurent Montel 2014-07-01 06:22:48 UTC
I close it. Reopen if necessary in 4.13.3