Skip to content

KSycocaFactory: Handle case when we failed to open KSycoca

Dāvis Mosāns requested to merge davism/kservice:ksycoca into master

If you get full ~/.cache then some applications like eg. Kate will fail to start with crash.

You can test that with

$ HOME=/dev/null kate

kf.service.sycoca: Couldn't create "/dev/null/.cache"
kf.service.sycoca: Couldn't create "/dev/null/.cache"
ASSERT: "str" in file /usr/src/debug/kservice-git/kservice/src/services/kservicefactory.cpp, line 31
KCrash: crashing... crashRecursionCounter = 2
KCrash: Application Name = kate path = /usr/bin pid = 482223
KCrash: Arguments: /usr/bin/kate

#0  0x00007f4322ca164c in ?? () from /usr/lib/libc.so.6
#1  0x00007f4322c51958 in raise () from /usr/lib/libc.so.6
#2  0x00007f43246f0465 in KCrash::defaultCrashHandler (sig=6) at /usr/src/debug/kcrash-git/kcrash/src/kcrash.cpp:618
#3  <signal handler called>
#4  0x00007f4322ca164c in ?? () from /usr/lib/libc.so.6
#5  0x00007f4322c51958 in raise () from /usr/lib/libc.so.6
#6  0x00007f4322c3b53d in abort () from /usr/lib/libc.so.6
#7  0x00007f432329fede in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5
#8  0x00007f432329ff3c in qt_assert(char const*, char const*, int) () from /usr/lib/libQt5Core.so.5
#9  0x00007f4323768749 in KServiceFactory::KServiceFactory (this=this@entry=0x55949673b500, db=<optimized out>) at /usr/src/debug/kservice-git/kservice/src/services/kservicefactory.cpp:31
#10 0x00007f432379f0b5 in KSycocaPrivate::serviceFactory (this=0x559496747950) at /usr/src/debug/kservice-git/kservice/src/sycoca/ksycoca.cpp:353
#11 0x00007f43237737fb in KService::serviceByStorageId (_storageId=...) at /usr/src/debug/kservice-git/kservice/src/services/kservice.cpp:632
#12 0x00007f4324ba687c in KateSessionManager::updateJumpListActions(QStringList const&) () from /usr/lib/libkateprivate.so.22.12.0
#13 0x00007f4324b9d21b in KateSessionManager::updateSessionList() () from /usr/lib/libkateprivate.so.22.12.0
#14 0x00007f4324bb223e in KateApp::KateApp(QCommandLineParser const&, KateApp::ApplicationMode, QString const&) () from /usr/lib/libkateprivate.so.22.12.0
#15 0x0000559495f5a4fc in ?? ()
#16 0x00007f4322c3c290 in ?? () from /usr/lib/libc.so.6
#17 0x00007f4322c3c34a in __libc_start_main () from /usr/lib/libc.so.6
#18 0x0000559495f5caf5 in ?? ()

This MR fixes that by checking if we successfully opened KSycoca

Merge request reports