Bug 311222

Summary: Applications that use Nepomuk crashes on exit if Nepomuk was disabled after their launch
Product: nepomuk Reporter: Eugene Shalygin <eugene.shalygin+bugzilla.kde>
Component: generalAssignee: Nepomuk Bugs Coordination <nepomuk-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: bladud, frank78ac
Priority: NOR    
Version: 4.8.90 (beta2)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 2.8.1

Description Eugene Shalygin 2012-12-05 19:01:37 UTC
Application: dolphin (2.1.85)
KDE Platform Version: 4.9.90 (Compiled from sources)
Qt Version: 4.8.4
Operating System: Linux 3.6.9 x86_64
Distribution: "NAME=Gentoo"

-- Information about the crash:
- What I was doing when the application crashed:
I can reproduce this with Dolphin and Kontact. Example with Dolphin:
1. Enable Nepomuk.
2. Start Dolphin
3. Disable Nepomuk.
4. Close Dolphin. It crashes

The crash can be reproduced every time.

-- Backtrace:
Application: Dolphin (kdeinit4), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f2e8f418780 (LWP 5178))]

Thread 3 (Thread 0x7f2e736f4700 (LWP 5183)):
#0  0x00007f2e8ca9316d in poll () from /lib64/libc.so.6
#1  0x00007f2e897b4304 in g_main_context_iterate.isra.23 () from /usr/lib64/libglib-2.0.so.0
#2  0x00007f2e897b4424 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#3  0x00007f2e8e0a6656 in QTextCodec::QTextCodec() () from /usr/lib64/qt4/libQtCore.so.4
#4  0x00000000034312b8 in ?? ()
#5  0x0000000002044320 in ?? ()
#6  0x00007f2e8e077d0f in normalizeTypeInternal(char const*, char const*, bool, bool) () from /usr/lib64/qt4/libQtCore.so.4
#7  0x00007f2e6c002b30 in ?? ()
#8  0x00000000034312d8 in ?? ()
#9  0x000000000342fee0 in ?? ()
#10 0x0000000003432430 in ?? ()
#11 0x00007f2e8e058caf in QFactoryLoader::updateDir(QString const&, QSettings&) () from /usr/lib64/qt4/libQtCore.so.4
#12 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7f2e7264b700 (LWP 5740)):
#0  0x00007f2e8ca95873 in select () from /lib64/libc.so.6
#1  0x00007f2e8e057232 in QPluginLoader::instance() () from /usr/lib64/qt4/libQtCore.so.4
#2  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f2e8f418780 (LWP 5178)):
[KCrash Handler]
#5  0x00007f2e84c324f0 in Soprano::Client::ClientConnection::isConnected() () from /usr/lib64/libsopranoclient.so.1
#6  0x00007f2e84c33322 in Soprano::Client::ClientModel::~ClientModel() () from /usr/lib64/libsopranoclient.so.1
#7  0x00007f2e84c33499 in Soprano::Client::ClientModel::~ClientModel() () from /usr/lib64/libsopranoclient.so.1
#8  0x00007f2e784b6b8e in ._163::destroy() () from /usr/lib64/libnepomukcore.so.4
#9  0x00007f2e8c9eceb1 in __run_exit_handlers () from /lib64/libc.so.6
#10 0x00007f2e8c9ecf35 in exit () from /lib64/libc.so.6
#11 0x000000000040895d in launch(int, char const*, char const*, char const*, int, char const*, bool, char const*, bool, char const*) ()
#12 0x00000000004097bb in handle_launcher_request(int, char const*) [clone .isra.13] ()
#13 0x0000000000409dfb in handle_requests(int) ()
#14 0x0000000000405b7f in main ()

Reported using DrKonqi
Comment 1 Frank Reininghaus 2012-12-05 19:19:48 UTC
Thanks for the bug report. Is there any evidence that this is a bug in Dolphin and not in Nepomuk/Soprano? I see only Nepomuk and Soprano functions in the backtrace.
Comment 2 Eugene Shalygin 2012-12-05 19:45:12 UTC
Well, I remember that I have seen Kontact crashed with the same backtrace. At that time I was playing with Nepomuk/Akonadi and addresses autocompletion in Kmail. But right now I can not reproduce it with Kontact anymore. Sorry.
Comment 3 Frank Reininghaus 2012-12-05 20:24:06 UTC
Thanks for the quick feedback. If different apps show the same behaviour, I think it's indeed a Nepomuk/Soprano bug.
Comment 4 Eugene Shalygin 2012-12-06 12:52:48 UTC
I managed to reproduce it with Kontact.
1. Enable Nepomuk.
2. Start Kontact
3. Open "New Message" window in KMail.
4. Try address autocompletion (that does not work)
5. Disable Nepomuk
6. Try address autocompletion again (works now)
7. Close Kontact. It crashes


Application: Kontact (kontact), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fc809c45780 (LWP 7201))]

Thread 2 (Thread 0x7fc804b88700 (LWP 7202)):
#0  0x00007fc817b73d1c in pthread_cond_wait () from /lib64/libpthread.so.0
#1  0x00007fc81c4faf6d in WTF::TCMalloc_PageHeap::scavengerThread() () from /usr/lib64/qt4/libQtWebKit.so.4
#2  0x00007fc81c4fb079 in WTF::TCMalloc_PageHeap::runScavengerThread(void*) () from /usr/lib64/qt4/libQtWebKit.so.4
#3  0x00007fc817b6ff3b in start_thread () from /lib64/libpthread.so.0
#4  0x00007fc81d22408d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7fc809c45780 (LWP 7201)):
[KCrash Handler]
#5  0x00007fc810c684f0 in Soprano::Client::ClientConnection::isConnected() () from /usr/lib64/libsopranoclient.so.1
#6  0x00007fc810c69322 in Soprano::Client::ClientModel::~ClientModel() () from /usr/lib64/libsopranoclient.so.1
#7  0x00007fc810c69499 in Soprano::Client::ClientModel::~ClientModel() () from /usr/lib64/libsopranoclient.so.1
#8  0x00007fc8132edb8e in ._163::destroy() () from /usr/lib64/libnepomukcore.so.4
#9  0x00007fc81d174eb1 in __run_exit_handlers () from /lib64/libc.so.6
#10 0x00007fc81d174f35 in exit () from /lib64/libc.so.6
#11 0x00007fc81d15e9bc in __libc_start_main () from /lib64/libc.so.6
#12 0x0000000000403e41 in _start ()
Comment 5 Simeon Bird 2012-12-09 04:36:35 UTC
Git commit 2122fc9eccefd381db7c830045c4fa65d2bffa63 by Simeon Bird.
Committed on 09/12/2012 at 05:31.
Pushed by sbird into branch '2.8'.

Avoid crash on destruction of ClientModel if nepomuk was disabled during
the lifetime of the ClientModel.

Crash is also fixed with 690e59e13a applied.

M  +1    -1    client/clientmodel.cpp

diff --git a/client/clientmodel.cpp b/client/clientmodel.cpp
index bdcbed3..4ac406b 100644
--- a/client/clientmodel.cpp
+++ b/client/clientmodel.cpp
@@ -50,7 +50,7 @@ Soprano::Client::ClientModel::~ClientModel()
     // closed by the server anyway.
     //
     QMutexLocker locker( &m_openIteratorsMutex );
-    if ( m_client->isConnected() ) {
+    if ( m_client && m_client->isConnected() ) {
         for ( int i = 0; i < m_openIterators.count(); ++i ) {
             m_client->iteratorClose( m_openIterators[i] );
         }