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

            Bug ID: 360946
           Summary: Baloo should handle lmdb corruption
           Product: frameworks-baloo
           Version: unspecified
          Platform: Chakra
                OS: Linux
            Status: UNCONFIRMED
          Severity: crash
          Priority: NOR
         Component: Engine
          Assignee: m...@vhanda.in
          Reporter: 0ink...@googlemail.com
                CC: pinak.ah...@gmail.com

When ~/.local/share/baloo/index, baloo will crash. The reason for this is that
in both positiondb.cpp and postingdb.cpp mdb_get is expected to either return
MDB_SUCCESS (0) or  to return MDB_NOTFOUND. However, in case of database
corruption mdb_get returns MDB_PAGE_NOTFOUND, as can be seen in the backtrace
below. Note that silently ignoring this error will not work, as further
database operations will yield MDB_BAD_TXN (Transaction cannot recover - it
must be aborted).


ASSERT failure in PositionDB::iter: "MDB_PAGE_NOTFOUND: Requested page not
found", file /home/fabian/projects/baloo/src/engine/positiondb.cpp, line 173

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffc00aa700 (LWP 15679)]
0x00007ffff457f5f8 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff457f5f8 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff4580a7a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff4d07391 in qt_message_fatal (context=..., message=<synthetic
pointer>) at global/qlogging.cpp:1610
#3  QMessageLogger::fatal (this=this@entry=0x7fffc00a8b60, 
    msg=msg@entry=0x7ffff4fb5fa0 "ASSERT failure in %s: \"%s\", file %s, line
%d") at global/qlogging.cpp:784
#4  0x00007ffff4d02721 in qt_assert_x (where=<optimized out>, what=<optimized
out>, file=<optimized out>, 
    line=<optimized out>) at global/qglobal.cpp:3002
#5  0x00007fffc02df51c in Baloo::PositionDB::iter (this=0x7fffc00a8c60,
term=...)
    at /home/fabian/projects/baloo/src/engine/positiondb.cpp:173
#6  0x00007fffc02e84fa in Baloo::Transaction::postingIterator
(this=0x7fffc00a98b0, query=...)
    at /home/fabian/projects/baloo/src/engine/transaction.cpp:312
#7  0x00007fffc07449f3 in Baloo::SearchStore::constructQuery
(this=0x7fffc00a99c0, tr=0x7fffc00a98b0, term=...)
    at /home/fabian/projects/baloo/src/lib/searchstore.cpp:283
#8  0x00007fffc0743cc7 in Baloo::SearchStore::constructQuery
(this=0x7fffc00a99c0, tr=0x7fffc00a98b0, term=...)
    at /home/fabian/projects/baloo/src/lib/searchstore.cpp:163
#9  0x00007fffc0743cc7 in Baloo::SearchStore::constructQuery
(this=0x7fffc00a99c0, tr=0x7fffc00a98b0, term=...)
    at /home/fabian/projects/baloo/src/lib/searchstore.cpp:163
#10 0x00007fffc074346d in Baloo::SearchStore::exec (this=0x7fffc00a99c0,
term=..., offset=0, limit=10, 
    sortResults=true) at /home/fabian/projects/baloo/src/lib/searchstore.cpp:75
#11 0x00007fffc0731466 in Baloo::Query::exec (this=0x7fffc00a9b40)
    at /home/fabian/projects/baloo/src/lib/query.cpp:210
#12 0x00007fffc0963710 in SearchRunner::match (this=this@entry=0x10aa080,
context=..., type=..., category=...)
    at
/chakra/core/plasma-workspace/src/plasma-workspace-5.6.0/runners/baloo/baloosearchrunner.cpp:99
#13 0x00007fffc09644c9 in SearchRunner::match (this=0x10aa080, context=...)
    at
/chakra/core/plasma-workspace/src/plasma-workspace-5.6.0/runners/baloo/baloosearchrunner.cpp:164
#14 0x00007fffd802b2d8 in Plasma::AbstractRunner::performMatch (this=0x10aa080,
localContext=...)
    at /chakra/core/krunner/src/krunner-5.20.0/src/abstractrunner.cpp:131
#15 0x00007fffcfdeffd0 in
ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&,
ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#16 0x00007fffcfdeeb70 in
ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&,
ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#17 0x00007fffcfdee67a in ThreadWeaver::Thread::run() () from
/usr/lib/libKF5ThreadWeaver.so.5
#18 0x00007ffff4d1f238 in QThreadPrivate::start (arg=0x10bbef0) at
thread/qthread_unix.cpp:340
#19 0x00007ffff2884464 in start_thread () from /usr/lib/libpthread.so.0
#20 0x00007ffff463512d in clone () from /usr/lib/libc.so.6


Reproducible: Always

Steps to Reproduce:
1. Corrupt your database
2. Cause a query
3.

Actual Results:  
In debug mode, the assertion is triggered. In release mode,  the cast will be
UB. This manifests in a traceback similar to #355280, as the data is corrupted.

Expected Results:  
Baloo handles the crash gracefully. Ideally, it would try to repair the
database or at least evict the bad data.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to