Bug 291305

Summary: We should check for connection validity before handling subscription request
Product: [Unmaintained] telepathy Reporter: Martin Klapetek <mklapetek>
Component: kded-moduleAssignee: Telepathy Bugs <kde-telepathy-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: dcbrown73, ddomenichelli, kde, mklapetek
Priority: NOR    
Version: git-latest   
Target Milestone: 0.4.0   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 285413    

Description Martin Klapetek 2012-01-11 22:07:09 UTC
Application: kded4 ($Id$)
KDE Platform Version: 4.7.97 (4.8 RC2 (4.7.97) (Compiled from sources)
Qt Version: 4.8.0
Operating System: Linux 3.0.0-14-generic x86_64
Distribution: Ubuntu 11.10

-- Information about the crash:
If one gets contact subscription request, then invalidate the connection (mission-control dies etc), the KSNI still stays in tray, but when the user tries to either approve or deny, the whole kded crashes because the connection is null.

Therefore - check for connection validity before handling this event.

The crash can be reproduced every time.

-- Backtrace:
Application: KDE Daemon (kdeinit4), signal: Segmentation fault
[Current thread is 1 (Thread 0x7f44b90887a0 (LWP 1589))]

Thread 3 (Thread 0x7f449a762700 (LWP 1649)):
#0  0x00007f44b2ee6518 in g_main_context_check () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007f44b2ee6f82 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f44b2ee7792 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f449aa3f516 in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#4  0x00007f44b2f0c2b6 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f44a824956c in ?? () from /usr/lib/nvidia-current-updates/libGL.so.1
#6  0x00007f44b774befc in start_thread (arg=0x7f449a762700) at pthread_create.c:304
#7  0x00007f44b61d089d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#8  0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7f4499d51700 (LWP 1662)):
#0  __pthread_mutex_unlock (mutex=0x7f44b774e000) at pthread_mutex_unlock.c:289
#1  0x00007f44b2ee667a in g_main_context_check () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f44b2ee6f82 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f44b2ee7429 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f44b7b5bbee in QEventDispatcherGlib::processEvents (this=0x19c6c90, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#5  0x00007f44b7b1d2a8 in QEventLoop::processEvents (this=0x7f4499d50c80, flags=...) at kernel/qeventloop.cpp:149
#6  0x00007f44b7b1d432 in QEventLoop::exec (this=0x7f4499d50c80, flags=...) at kernel/qeventloop.cpp:204
#7  0x00007f44b79ea2a7 in QThread::exec (this=0x186fbd0) at thread/qthread.cpp:501
#8  0x00007f44b7af86fb in QInotifyFileSystemWatcherEngine::run (this=0x186fbd0) at io/qfilesystemwatcher_inotify.cpp:248
#9  0x00007f44b79ecbd4 in QThreadPrivate::start (arg=0x186fbd0) at thread/qthread_unix.cpp:298
#10 0x00007f44a824956c in ?? () from /usr/lib/nvidia-current-updates/libGL.so.1
#11 0x00007f44b774befc in start_thread (arg=0x7f4499d51700) at pthread_create.c:304
#12 0x00007f44b61d089d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#13 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f44b90887a0 (LWP 1589)):
[KCrash Handler]
#6  Tp::ContactManager::connection (this=0x0) at /home/mck182/Work/Telepathy/telepathy-qt4/TelepathyQt/contact-manager.cpp:202
#7  0x00007f4497a6ce04 in Tp::ContactManager::removePresencePublication (this=0x0, contacts=..., message=...) at /home/mck182/Work/Telepathy/telepathy-qt4/TelepathyQt/contact-manager.cpp:832
#8  0x00007f4491c640ba in ContactRequestHandler::onContactRequestDenied (this=0x1b6bd20) at /home/mck182/Work/Telepathy/telepathy-kded-module/contact-request-handler.cpp:306
#9  0x00007f4491c65281 in ContactRequestHandler::qt_metacall (this=0x1b6bd20, _c=QMetaObject::InvokeMetaMethod, _id=8, _a=0x7fffb5f952a0) at /home/mck182/Work/Telepathy/telepathy-kded-module/build/contact-request-handler.moc:104
#10 0x00007f44b7b27e9c in QMetaObject::metacall (object=0x1b6bd20, cl=QMetaObject::InvokeMetaMethod, idx=12, argv=0x7fffb5f952a0) at kernel/qmetaobject.cpp:245
#11 0x00007f44b7b3de8d in QMetaObject::activate (sender=0x1837f40, m=0x7f44b77028c0, local_signal_index=1, argv=0x7fffb5f952a0) at kernel/qobject.cpp:3566
#12 0x00007f44b6986ff8 in QAction::triggered (this=0x1837f40, _t1=false) at .moc/debug-shared/moc_qaction.cpp:277
#13 0x00007f44b69862b8 in QAction::activate (this=0x1837f40, event=QAction::Trigger) at kernel/qaction.cpp:1257
#14 0x00007f44b69876d7 in QAction::trigger (this=0x1837f40) at kernel/qaction.h:218
#15 0x00007f44b698668a in QAction::qt_static_metacall (_o=0x1837f40, _c=QMetaObject::InvokeMetaMethod, _id=8, _a=0x20f1780) at .moc/debug-shared/moc_qaction.cpp:151
#16 0x00007f44b7b377e5 in QMetaCallEvent::placeMetaCall (this=0x1faa9a0, object=0x1837f40) at kernel/qobject.cpp:525
#17 0x00007f44b7b38a23 in QObject::event (this=0x1837f40, e=0x1faa9a0) at kernel/qobject.cpp:1195
#18 0x00007f44b6986044 in QAction::event (this=0x1837f40, e=0x1faa9a0) at kernel/qaction.cpp:1187
#19 0x00007f44b88a3e7e in KAction::event (this=0x1837f40, event=0x1faa9a0) at /build/buildd/project-neon-kdelibs-2+git20120110+r92380/kdeui/actions/kaction.cpp:131
#20 0x00007f44b69967ea in QApplicationPrivate::notify_helper (this=0x15d3970, receiver=0x1837f40, e=0x1faa9a0) at kernel/qapplication.cpp:4550
#21 0x00007f44b6993e08 in QApplication::notify (this=0x7fffb5f960f0, receiver=0x1837f40, e=0x1faa9a0) at kernel/qapplication.cpp:3932
#22 0x00007f44b89af80f in KApplication::notify (this=0x7fffb5f960f0, receiver=0x1837f40, event=0x1faa9a0) at /build/buildd/project-neon-kdelibs-2+git20120110+r92380/kdeui/kernel/kapplication.cpp:311
#23 0x00007f44b7b1f9de in QCoreApplication::notifyInternal (this=0x7fffb5f960f0, receiver=0x1837f40, event=0x1faa9a0) at kernel/qcoreapplication.cpp:876
#24 0x00007f44b7b23551 in QCoreApplication::sendEvent (receiver=0x1837f40, event=0x1faa9a0) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#25 0x00007f44b7b209f2 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x151d2b0) at kernel/qcoreapplication.cpp:1500
#26 0x00007f44b7b20613 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1393
#27 0x00007f44b7b5c31b in QCoreApplication::sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#28 0x00007f44b7b5b2f4 in postEventSourceDispatch (s=0x15d7310) at kernel/qeventdispatcher_glib.cpp:279
#29 0x00007f44b2ee6a5d in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007f44b2ee7258 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#31 0x00007f44b2ee7429 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x00007f44b7b5bbcb in QEventDispatcherGlib::processEvents (this=0x151f7d0, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#33 0x00007f44b6a6ee78 in QGuiEventDispatcherGlib::processEvents (this=0x151f7d0, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#34 0x00007f44b7b1d2a8 in QEventLoop::processEvents (this=0x7fffb5f96050, flags=...) at kernel/qeventloop.cpp:149
#35 0x00007f44b7b1d432 in QEventLoop::exec (this=0x7fffb5f96050, flags=...) at kernel/qeventloop.cpp:204
#36 0x00007f44b7b2005e in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1148
#37 0x00007f44b69939f2 in QApplication::exec () at kernel/qapplication.cpp:3811
#38 0x00007f44a40a6fb6 in kdemain (argc=1, argv=0x164b250) at /build/buildd/project-neon-kdelibs-2+git20120110+r92380/kded/kded.cpp:924
#39 0x0000000000406d7f in launch (argc=1, _name=0x40da82 "kded4", args=0x0, cwd=0x0, envc=0, envs=0x0, reset_env=false, tty=0x0, avoid_loops=false, startup_id_str=0x40d337 "0") at /build/buildd/project-neon-kdelibs-2+git20120110+r92380/kinit/kinit.cpp:734
#40 0x000000000040a07a in main (argc=4, argv=0x7fffb5f96968, envp=0x7fffb5f96990) at /build/buildd/project-neon-kdelibs-2+git20120110+r92380/kinit/kinit.cpp:1849

Reported using DrKonqi
Comment 1 David Edmundson 2012-01-11 22:16:38 UTC
Actually from this BT it's the ContactManager that is nulled not the connection.

#7  0x00007f4497a6ce04 in Tp::ContactManager::removePresencePublication
(this=0x0, contacts=..., message=...) at
Comment 2 Martin Klapetek 2012-01-22 12:12:00 UTC
Git commit b12961cb4422a63e51974b1358dc8dbd0df02bbc by Martin Klapetek.
Committed on 22/01/2012 at 11:58.
Pushed by mklapetek into branch 'master'.

Check for contact manager being null and don't crash if it is.

I had a contact request, killed mc, accepted it and the whole kded didn't crash and the contact was still added. Double win.

Reviewed-by: David Edmundson

M  +12   -8    contact-request-handler.cpp

http://commits.kde.org/telepathy-kded-module/b12961cb4422a63e51974b1358dc8dbd0df02bbc
Comment 3 David Edmundson 2012-06-22 15:51:58 UTC
*** Bug 302351 has been marked as a duplicate of this bug. ***
Comment 4 David Edmundson 2012-08-09 09:02:21 UTC
*** Bug 303124 has been marked as a duplicate of this bug. ***
Comment 5 David Edmundson 2012-12-11 23:59:12 UTC
*** Bug 308915 has been marked as a duplicate of this bug. ***