Bug 276383

Summary: Kopete crashes when trying to create HistoryLogger with empty m_manager->members();
Product: [Unmaintained] kopete Reporter: Oleksandr Senkovych <bjsenya>
Component: generalAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: sreejiththulaseedharan
Priority: NOR    
Version: 1.0.80   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Oleksandr Senkovych 2011-06-24 11:00:53 UTC
Application: kopete (1.0.80)
KDE Platform Version: 4.6.80 (4.7 Beta1)
Qt Version: 4.7.2
Operating System: Linux 2.6.39-gentoo-r1 i686
Distribution (Platform): Gentoo Packages

-- Information about the crash:
Kopete crashes occured during group conversations.
I tried to debug it and found that in HistoryGuiClient constructor (historyguiclient.cpp):

HistoryGUIClient::HistoryGUIClient ( Kopete::ChatSession *parent )
		: QObject ( parent ), KXMLGUIClient ( parent )
{
...
Here you check if QList is empty
if ( !m_manager || m_manager->members().isEmpty() )
	deleteLater();
But even if (m_manager->members().isEmpty() == true), method deleteLater() doesn't break run progress, so under certain circumstances you can reference to the first element of the empty list and segfault will occur: 

QList<Kopete::Contact*> mb=m_manager->members();
m_logger=new HistoryLogger ( mb.first() , this ); <--- Here comes segfault!
 
For some reason it happens very often on my computer and kopete becomes unusable - it crashes every 5 minutes due to this error.

The crash can be reproduced some of the time.

-- Backtrace:
Application: Kopete (kopete), signal: Aborted
[Current thread is 1 (Thread 0xb47e7a70 (LWP 2278))]

Thread 4 (Thread 0xb1201b70 (LWP 2292)):
#0  0xb5058276 in clock_gettime () from /lib/librt.so.1
#1  0xb6913ff8 in ?? () from /usr/lib/qt4/libQtCore.so.4
#2  0xb69e9625 in ?? () from /usr/lib/qt4/libQtCore.so.4
#3  0xb69e966a in ?? () from /usr/lib/qt4/libQtCore.so.4
#4  0xb69e7708 in ?? () from /usr/lib/qt4/libQtCore.so.4
#5  0xb69e779d in ?? () from /usr/lib/qt4/libQtCore.so.4
#6  0xb4f960f2 in g_main_context_prepare () from /usr/lib/libglib-2.0.so.0
#7  0xb4f96509 in ?? () from /usr/lib/libglib-2.0.so.0
#8  0xb4f96ad8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#9  0xb69e74ff in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#10 0xb69b7989 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#11 0xb69b7e0a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#12 0xb258e00a in QCA::SyncThread::run() () from /usr/lib/qca2/libqca.so.2
#13 0xb68b9702 in ?? () from /usr/lib/qt4/libQtCore.so.4
#14 0xb5a71cf2 in start_thread () from /lib/libpthread.so.0
#15 0xb5bbd84e in clone () from /lib/libc.so.6

Thread 3 (Thread 0xb0a00b70 (LWP 2293)):
#0  0xb7732424 in __kernel_vsyscall ()
#1  0xb5bb3156 in poll () from /lib/libc.so.6
#2  0xb4fa3bbb in g_poll () from /usr/lib/libglib-2.0.so.0
#3  0xb4f966cc in ?? () from /usr/lib/libglib-2.0.so.0
#4  0xb4f96ad8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#5  0xb69e74ff in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#6  0xb69b7989 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#7  0xb69b7e0a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#8  0xb27d77ea in XMPP::SyncThread::run (this=0x8d13580) at /home/blackjack/kopete/work/kopete-9999/kopete/protocols/jabber/libiris/iris/irisnet/corelib/netinterface.cpp:151
#9  0xb68b9702 in ?? () from /usr/lib/qt4/libQtCore.so.4
#10 0xb5a71cf2 in start_thread () from /lib/libpthread.so.0
#11 0xb5bbd84e in clone () from /lib/libc.so.6

Thread 2 (Thread 0xb01ffb70 (LWP 2307)):
#0  0xb7732424 in __kernel_vsyscall ()
#1  0xb5bb67c1 in select () from /lib/libc.so.6
#2  0xb2502458 in posix_timer_do () from /usr/lib/libortp.so.8
#3  0xb25030fa in rtp_scheduler_schedule () from /usr/lib/libortp.so.8
#4  0xb5a71cf2 in start_thread () from /lib/libpthread.so.0
#5  0xb5bbd84e in clone () from /lib/libc.so.6

Thread 1 (Thread 0xb47e7a70 (LWP 2278)):
[KCrash Handler]
#7  0xb7732424 in __kernel_vsyscall ()
#8  0xb5b196a1 in raise () from /lib/libc.so.6
#9  0xb5b1ade2 in abort () from /lib/libc.so.6
#10 0xb68af27c in qt_message_output(QtMsgType, char const*) () from /usr/lib/qt4/libQtCore.so.4
#11 0xb68af42a in ?? () from /usr/lib/qt4/libQtCore.so.4
#12 0xb68af539 in qFatal(char const*, ...) () from /usr/lib/qt4/libQtCore.so.4
#13 0xb68af5c5 in qt_assert(char const*, char const*, int) () from /usr/lib/qt4/libQtCore.so.4
#14 0xb2aad7f9 in QList<Kopete::Contact*>::first (this=0xbf98305c) at /usr/include/qt4/QtCore/qlist.h:269
#15 0xb2ac74bb in HistoryGUIClient::HistoryGUIClient (this=0xa882e10, parent=0x9b67d30) at /home/blackjack/kopete/work/kopete-9999/kopete/plugins/history/historyguiclient.cpp:53
#16 0xb2aaaaa1 in HistoryPlugin::messageDisplayed (this=0x891a6c0, m=...) at /home/blackjack/kopete/work/kopete-9999/kopete/plugins/history/historyplugin.cpp:116
#17 0xb2aaac1b in HistoryMessageLogger::handleMessage (this=0xafc1020, event=0xb217750) at /home/blackjack/kopete/work/kopete-9999/kopete/plugins/history/historyplugin.cpp:103
#18 0xb75a46dc in Kopete::MessageHandler::handleMessageInternal (this=0xafc1020, event=0xb217750) at /home/blackjack/kopete/work/kopete-9999/kopete/libkopete/kopetemessagehandler.cpp:60
#19 0xb75a27e9 in Kopete::ProcessMessageTask::start (this=0xa884460) at /home/blackjack/kopete/work/kopete-9999/kopete/libkopete/kopetemessagehandlerchain.cpp:166
#20 0xb75a2783 in Kopete::ProcessMessageTask::qt_metacall (this=0xa884460, _c=QMetaObject::InvokeMetaMethod, _id=28, _a=0x9aaf698) at /home/blackjack/kopete/work/kopete-9999_build/kopete/libkopete/kopetemessagehandlerchain.moc:124
#21 0xb69bebfa in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/qt4/libQtCore.so.4
#22 0xb69c9f16 in QMetaCallEvent::placeMetaCall(QObject*) () from /usr/lib/qt4/libQtCore.so.4
#23 0xb69cb852 in QObject::event(QEvent*) () from /usr/lib/qt4/libQtCore.so.4
#24 0xb5e7e7dc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/qt4/libQtGui.so.4
#25 0xb5e8400e in QApplication::notify(QObject*, QEvent*) () from /usr/lib/qt4/libQtGui.so.4
#26 0xb6fc028a in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#27 0xb69b8ebb in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/qt4/libQtCore.so.4
#28 0xb69bc12c in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/qt4/libQtCore.so.4
#29 0xb69bc28d in QCoreApplication::sendPostedEvents(QObject*, int) () from /usr/lib/qt4/libQtCore.so.4
#30 0xb69e79d4 in ?? () from /usr/lib/qt4/libQtCore.so.4
#31 0xb4f92355 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#32 0xb4f968f8 in ?? () from /usr/lib/libglib-2.0.so.0
#33 0xb4f96ad8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#34 0xb69e74c5 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#35 0xb5f3e675 in ?? () from /usr/lib/qt4/libQtGui.so.4
#36 0xb69b7989 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#37 0xb69b7e0a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#38 0xb69bc34f in QCoreApplication::exec() () from /usr/lib/qt4/libQtCore.so.4
#39 0xb5e7d4f7 in QApplication::exec() () from /usr/lib/qt4/libQtGui.so.4
#40 0x0805a3ee in _start ()

Reported using DrKonqi