Bug 333930

Summary: Gracefully handle Xapian DB Corruption
Product: [Unmaintained] Baloo Reporter: Matt Scheirer <matt.scheirer>
Component: Baloo File DaemonAssignee: Vishesh Handa <me>
Status: RESOLVED FIXED    
Severity: crash CC: frank78ac, ivan.cukic
Priority: NOR Keywords: drkonqi
Version First Reported In: 4.13   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.4
Sentry Crash Report:

Description Matt Scheirer 2014-04-26 18:10:54 UTC
Application: dolphin (4.13.0)
KDE Platform Version: 4.13.0
Qt Version: 4.8.6
Operating System: Linux 3.14.1-1-ARCH x86_64
Distribution: "Arch Linux"

-- Information about the crash:
If I have tooltips enabled in Dolphin, but don't have local/kdemultimedia-mplayerthumbs installed (Arch package), Dolphin crashes on folder mouseovers.  This is under 4.13.0-1 of all packages involved.

Of note, video previews still work fine via the ffmpegthumbs.

I would not expect that dolphin folder previews wouldn't depend on a package that only specifies media files.

The crash can be reproduced every time.

-- Backtrace:
Application: Dolphin (dolphin), signal: Aborted
Using host libthread_db library "/usr/lib/libthread_db.so.1".
To enable execution of this file add
	add-auto-load-safe-path /usr/lib/libstdc++.so.6.0.19-gdb.py
line to your configuration file "/home/zanny/.gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/home/zanny/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Current thread is 1 (Thread 0x7f57ab654780 (LWP 2025))]

Thread 3 (Thread 0x7f578e9fd700 (LWP 2026)):
#0  0x00007f57a8c9f35d in poll () from /usr/lib/libc.so.6
#1  0x00007f57a5db2d64 in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f57a5db2e6c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f57aa2df2c6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#4  0x00007f57aa2b115f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#5  0x00007f57aa2b1455 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#6  0x00007f57aa1ad7ef in QThread::exec() () from /usr/lib/libQtCore.so.4
#7  0x00007f57aa292943 in ?? () from /usr/lib/libQtCore.so.4
#8  0x00007f57aa1afebf in ?? () from /usr/lib/libQtCore.so.4
#9  0x00007f57a9f200a2 in start_thread () from /usr/lib/libpthread.so.0
#10 0x00007f57a8ca7d1d in clone () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7f578e152700 (LWP 2027)):
#0  0x00007f57a8c9f35d in poll () from /usr/lib/libc.so.6
#1  0x00007f57a5db2d64 in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f57a5db2e6c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f57aa2df2c6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#4  0x00007f57aa2b115f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#5  0x00007f57aa2b1455 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#6  0x00007f57aa1ad7ef in QThread::exec() () from /usr/lib/libQtCore.so.4
#7  0x00007f57aa1afebf in ?? () from /usr/lib/libQtCore.so.4
#8  0x00007f57a9f200a2 in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f57a8ca7d1d in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f57ab654780 (LWP 2025)):
[KCrash Handler]
#5  0x00007f57a8bf7389 in raise () from /usr/lib/libc.so.6
#6  0x00007f57a8bf8788 in abort () from /usr/lib/libc.so.6
#7  0x00007f57a8fca625 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#8  0x00007f57a8fc8786 in ?? () from /usr/lib/libstdc++.so.6
#9  0x00007f57a8fc87b3 in std::terminate() () from /usr/lib/libstdc++.so.6
#10 0x00007f57a8fc8a46 in __cxa_rethrow () from /usr/lib/libstdc++.so.6
#11 0x00007f57aa2b1646 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#12 0x00007f57aa2b6719 in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#13 0x00007f5795b95417 in kdemain () from /usr/lib/libkdeinit4_dolphin.so
#14 0x0000000000408060 in _start ()

Possible duplicates by query: bug 333840, bug 333821, bug 333729, bug 333701, bug 333693.

Reported using DrKonqi
Comment 1 Christoph Feck 2014-04-27 00:45:28 UTC
Probably Baloo crashing because missing exception handling. If this is reproducible, could you please try to get a backtrace of the uncaught exception? For more information, please see http://techbase.kde.org/Development/Tutorials/Debugging/How_to_create_useful_crash_reports#Retrieving_a_backtrace_when_an_uncaught_exception_is_causing_a_crash
Comment 2 Matt Scheirer 2014-04-27 12:46:03 UTC
I did some more research and testing and it is always due to the same issue reported here:

https://bugs.kde.org/show_bug.cgi?id=333772

Basically, the baloo database files in ~/.local/share/baloo/ get in incomplete states during power loss, and when the system is brought back up it crashes when it can't handle. This is the sweet stuff:


baloo_file(12183): Error opening table `/home/zanny/.local/share/baloo/file//record.':
Unable to read revision from /home/zanny/.local/share/baloo/file//record.baseA
Unable to read revision from /home/zanny/.local/share/baloo/file//record.baseB
  DatabaseOpeningError: Error opening table `/home/zanny/.local/share/baloo/file//record.':
Unable to read revision from /home/zanny/.local/share/baloo/file//record.baseA
Unable to read revision from /home/zanny/.local/share/baloo/file//record.baseB

I should have saved copies of these bad records before I trashed the folder to see if it could start over, but wiping the contents did work for this dolphin bug.
Comment 3 Ivan Čukić 2014-05-11 19:40:56 UTC
I have confirmed the behaviour.

Baloo does not handle the exceptions coming from xapian, and they get propagated to the qt's event loop which does not handle exceptions.

> 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 'Xapian::DatabaseCorruptError'

The backtrace is useless since it happens in the event loop.
Comment 4 Vishesh Handa 2014-07-21 09:28:51 UTC
Adding a crash which occurs after the DB gets corrupted -

Application: Baloo File (baloo_file), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fa99720c800 (LWP 2340))]

Thread 2 (Thread 0x7fa980d88700 (LWP 2343)):
#0  0x00007fa992fa6fbd in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fa991ecbb72 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007fa991ecd64f in xcb_wait_for_event () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007fa982926c89 in QXcbEventReader::run (this=0x1163d10) at qxcbconnection.cpp:1043
#4  0x00007fa993844e11 in QThreadPrivate::start (arg=0x1163d10) at thread/qthread_unix.cpp:345
#5  0x00007fa992ca3182 in start_thread (arg=0x7fa980d88700) at pthread_create.c:312
#6  0x00007fa992fb430d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7fa99720c800 (LWP 2340)):
[KCrash Handler]
#6  size (this=<optimized out>, this=<optimized out>) at /usr/include/c++/4.8/bits/stl_vector.h:646
#7  Xapian::Database::get_document (this=0x0, did=815390) at ../api/omdatabase.cc:439
#8  0x00007fa995e59b34 in Baloo::XapianDatabase::document (this=0x1183ba0, id=815390) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/src/xapian/xapiandatabase.cpp:167
#9  0x000000000044032f in Baloo::BasicIndexingQueue::shouldIndex (this=0x11c0d40, file=..., mimetype=...) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/src/file/basicindexingqueue.cpp:146
#10 0x000000000043fdd5 in Baloo::BasicIndexingQueue::process (this=0x11c0d40, file=..., flags=...) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/src/file/basicindexingqueue.cpp:104
#11 0x000000000043fc83 in Baloo::BasicIndexingQueue::enqueue (this=0x43fc83 <Baloo::BasicIndexingQueue::enqueue(Baloo::FileMapping const&, QFlags<Baloo::UpdateDirFlag>)+279>, file=..., flags=...) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/src/file/basicindexingqueue.cpp:79
#12 0x000000000043f72e in Baloo::IndexingQueue::processNext (this=0x11c0d40) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/src/file/indexingqueue.cpp:42
#13 0x0000000000450ace in Baloo::IndexingQueue::qt_static_metacall (_o=0x11c0d40, _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0x2027780) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/obj-x86_64-linux-gnu/src/file/moc_indexingqueue.cpp:92
#14 0x00007fa993aed8f7 in QMetaCallEvent::placeMetaCall (this=0x2026570, object=0x11c0d40) at kernel/qobject.cpp:487
#15 0x00007fa993aee93c in QObject::event (this=0x11c0d40, e=0x2026570) at kernel/qobject.cpp:1241
#16 0x00007fa9947053fa in QApplicationPrivate::notify_helper (this=0x114a670, receiver=0x11c0d40, e=0x2026570) at kernel/qapplication.cpp:3522
#17 0x00007fa994702a42 in QApplication::notify (this=0x7fffb9cccf80, receiver=0x11c0d40, e=0x2026570) at kernel/qapplication.cpp:2975
#18 0x00007fa993ab342a in QCoreApplication::notifyInternal (this=0x7fffb9cccf80, receiver=0x11c0d40, event=0x2026570) at kernel/qcoreapplication.cpp:935
#19 0x00007fa993ab6fb7 in QCoreApplication::sendEvent (receiver=0x11c0d40, event=0x2026570) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:237
#20 0x00007fa993ab46f5 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x1148360) at kernel/qcoreapplication.cpp:1539
#21 0x00007fa993ab409a in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1397
#22 0x00007fa993b2927c in postEventSourceDispatch (s=0x1186340) at kernel/qeventdispatcher_glib.cpp:279
#23 0x00007fa98c9dee04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007fa98c9df048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007fa98c9df0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#26 0x00007fa993b29a1d in QEventDispatcherGlib::processEvents (this=0x1174f40, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#27 0x00007fa982980cf2 in QPAEventDispatcherGlib::processEvents (this=0x1174f40, flags=...) at eventdispatchers/qeventdispatcher_glib.cpp:123
#28 0x00007fa993ab0162 in QEventLoop::processEvents (this=0x7fffb9cccdd0, flags=...) at kernel/qeventloop.cpp:136
#29 0x00007fa993ab0423 in QEventLoop::exec (this=0x7fffb9cccdd0, flags=...) at kernel/qeventloop.cpp:212
#30 0x00007fa993ab3ae2 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1188
#31 0x00007fa993e994e0 in QGuiApplication::exec () at kernel/qguiapplication.cpp:1446
#32 0x00007fa994702263 in QApplication::exec () at kernel/qapplication.cpp:2767
#33 0x000000000042ece8 in main (argc=1, argv=0x7fffb9ccd1b8) at /build/buildd/project-neon5-baloo-0.0+git20140721.0312+neon4~715c35e~14.04/src/file/main.cpp:107
Comment 5 Vishesh Handa 2015-05-11 11:07:46 UTC
Fixed with Plasma 5.4. We are no longer using Xapian.