Bug 101626

Summary: kopete issues millions of alerts and eats up all memory
Product: [Unmaintained] kopete Reporter: Leo Savernik <l.savernik>
Component: ICQ and AIM PluginsAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: cshobe, jpowers, kdebugs, mattr, mirya, mmodem00, p.dania, smgiles, sven.burmeister
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Leo Savernik 2005-03-16 16:26:01 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Compiled From Sources
Compiler:          gcc 2.95.2 
OS:                Linux

Kopete had been running for approx. 2 days. I issued a compile session, left the pc running and went to bed. The internet connection was offline throughout that time.

At about 2:00 I was woken up by a never ending series of glass-breaking-sounds (you normally get if an error dialog pops up) at rapid pace. Yet no single actual error dialog popped up, so I considered it to be strange static caused by interferences due to compilation. So I simply muted the speakers and went to bed again.

When I returned from work at about 16:00, the system was virtually at stillstand. Top showed the culprit - kopete, having consumed insane amounts of memory:

23585 leo       18   0  678M 253M 23732 S     2.8 50.2  71:10 kopete
26108 leo       13   0  678M 253M 23732 S     0.0 50.2   0:06 kopete
22885 leo       11   0  678M 253M 23732 S     0.0 50.2   0:00 kopete
22886 leo       13   0  678M 253M 23732 S     0.0 50.2   0:00 kopete

I unmuted the speakers, and the glass was still breaking, the pace between two breaks has slowed down to a multitude of seconds, though.

As the compile job had finished, it was clear what I was hearing is the real error-sound. However, there were still no error dialogs.

I was hardly able to copy the above trace, and afterwards I had to kill kopete to return to a usable system, so I couldn't do further investigations.

For the records, I'm using KDE 3.4.0/Qt 3.3.4.

This bug might be related to bug 71972.

I'll compile a kopete version with full debug output in the hope it'll give me a clue.
Comment 1 Leo Savernik 2005-03-16 16:38:57 UTC
I meant related to bug 71975.
Comment 2 Jason Keirstead 2005-03-16 16:59:06 UTC
On Wednesday 16 March 2005 11:38 am, Leo Savernik wrote:
> ------- Additional Comments From l.savernik aon at  2005-03-16 16:38
> ------- I meant related to bug 71975.


According to bug 71975, it only happens in some QT 3.3 snapshots.

Are you using a 3.3 snapshot? Have you tried upgrading your QT?
Comment 3 Matt Rogers 2005-03-16 17:06:09 UTC
i don't think leo will be upgrading to qt 4 anytime soon. ;) qt 3.3.4 is the latest available. I'm not really sure what would cause the alerts, especially ones w/o dialog boxes. were you connected before you shut down the internet connection?
Comment 4 Thiago Macieira 2005-03-16 17:21:06 UTC
It would be interesting to know which protocols were connected when you went to bed.
Comment 5 Leo Savernik 2005-03-16 18:08:14 UTC
As I've mentioned earlier, I'm using Qt 3.3.4, no snapshot (and no versions from the future ;-) )

I did what I've always done, without detriment so far.

ICQ was connected. Then I cut the internet connection without explicitly going offline in kopete (because it notices within some time, and'll go offline by itself).

If the sudden disconnect from the internet is the actual cause for this behaviour, I wonder why it needed two hours to show side effects (I disconnected at about 23:50).

Comment 6 Leo Savernik 2005-03-17 16:17:59 UTC
Status update:

I recompiled kopete cvs from yesterday (2005-03-16) with full debug information and did the following test:

After having configured kopete with account and contact information, I went online, left it running for some hours, then, around midnight, I disconnected the internet link without going offline in kopete explicitly, and went to bed.

When returning from work today at about 16:00, the box was frozen and kopete had again hogged 683Mb (!) of memory:

29758 kderun     8   0  683M 252M 60204 S     0.0 50.0   0:06 kopete
29757 kderun     9   0  683M 252M 60204 D     0.0 50.0 125:51 kopete

At the time of killing kopete the debug output log had grown over 95Mb (!), mostly containing lines like:

QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()
kopete (oscar - raw protocol): [void KNetworkConnector::done()]
kopete (oscar - raw protocol): [void KNetworkByteStream::close()] Closing stream
.
kopete (oscar - raw protocol): [void KNetworkConnector::connectToServer(const QS
tring &)] Initiating connection to login.oscar.aol.com
kopete (oscar - raw protocol): [bool KNetworkByteStream::connect(QString, QStrin
g)] Connecting to login.oscar.aol.com, service 5190
kopete (oscar - raw protocol): [void KNetworkConnector::done()]
kopete (oscar - raw protocol): [void KNetworkByteStream::close()] Closing stream
.
kopete (oscar - raw protocol): [void KNetworkByteStream::slotError(int)] Socket
error 1
kopete (oscar - raw protocol): [void KNetworkConnector::slotError(int)] Error de
tected: 1
kopete (oscar - raw protocol): [void ClientStream::cr_error()]
kopete (oscar - raw protocol): [void KNetworkConnector::done()]
kopete (oscar - raw protocol): [void KNetworkByteStream::close()] Closing stream
.
kopete (oscar): [void OscarAccount::protocolError(int, int, const QString &)] Re
ceived fatal protocol error3, 0
kopete (oscar): [void OscarAccount::disconnect()] accountId='xxxxx4208'
libkopete: [void Kopete::Account::slotOnlineStatusChanged(Kopete::Contact *, con
st Kopete::OnlineStatus &, const Kopete::OnlineStatus &)] account xxxxx4208 chang
ed status. was Connecting, is Offline
kopete (oscar/icq): [void ICQAccount::disconnected(Kopete::Account::DisconnectRe
ason)] Attempting to set status offline
libkopete: [void Kopete::Account::slotOnlineStatusChanged(Kopete::Contact *, con
st Kopete::OnlineStatus &, const Kopete::OnlineStatus &)] account xxxxx4208 chang
ed status. was Offline, is Offline
kopete (oscar/icq): [void ICQAccount::disconnected(Kopete::Account::DisconnectRe
ason)] Attempting to set status offline
kopete (oscar - raw protocol): [void KNetworkConnector::done()]
kopete (oscar - raw protocol): [void KNetworkByteStream::close()] Closing stream
.
kopete (oscar/icq): [void ICQAccount::connectWithPassword(const QString &)] acco
untId='xxxxx4208'
libkopete: [void Kopete::Account::slotOnlineStatusChanged(Kopete::Contact *, con
st Kopete::OnlineStatus &, const Kopete::OnlineStatus &)] account xxxxx4208 chang
ed status. was Offline, is Connecting
kopete (oscar/icq): [void ICQAccount::connectWithPassword(const QString &)] Logg
ing in as xxxxx4208
kopete (oscar - raw protocol): [KNetworkConnector::KNetworkConnector(QObject * =
 0, const char * = 0)] New KNetwork connector.
kopete (oscar - raw protocol): [KNetworkByteStream::KNetworkByteStream(QObject *
 = 0, const char * = 0)] Instantiating new KNetwork byte stream.
kopete (oscar - raw protocol): [void KNetworkConnector::setOptHostPort(const QSt
ring &, short unsigned int)] Manually specifying host login.oscar.aol.com and po
rt 5190
QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()
kopete (oscar - raw protocol): [void KNetworkConnector::done()]
kopete (oscar - raw protocol): [void KNetworkByteStream::close()] Closing stream
.

So there seems to be a twofold bug in the disconnection routine. First, it seems to busy-wait (125 min of cpu time), second, it seems to have a memory leak there.

Given that kopete 3.3 and earlier versions handled unexpected disconnection from the internet gracefully, I consider this behaviour severely buggy that needs fixing soon.

I'll leave the monster-log on my disk for a while in case you need more information.
Comment 7 Thiago Macieira 2005-03-29 00:03:28 UTC
*** Bug 102684 has been marked as a duplicate of this bug. ***
Comment 8 Thiago Macieira 2005-03-30 15:20:31 UTC
*** Bug 102844 has been marked as a duplicate of this bug. ***
Comment 9 Matt Rogers 2005-04-01 16:56:41 UTC
*** Bug 103002 has been marked as a duplicate of this bug. ***
Comment 10 Matt Rogers 2005-04-02 06:34:33 UTC
CVS commit by mattr: 

Display only one error when we hit an unknown error that I don't do a good
job of handling yet. You get to choose whether or not to reconnect now.

BUG: 100064
CCBUG: 101626


  M +1 -1      oscaraccount.cpp   1.174
  M +3 -27     liboscar/client.cpp   1.13
  M +0 -2      liboscar/client.h   1.12
  M +5 -5      liboscar/connectionlist.cpp   1.3


--- kdenetwork/kopete/protocols/oscar/oscaraccount.cpp  #1.173:1.174
@@ -248,5 +248,5 @@ void OscarAccount:: protocolError( int e
                 if ( psError == 0 ) //zero is a generic error when i don't know what's wrong. :/
                 {
-                        disconnected( Kopete::Account::ConnectionReset );
+                        disconnected( Kopete::Account::Manual );
                 }
                 

--- kdenetwork/kopete/protocols/oscar/liboscar/client.cpp  #1.12:1.13
@@ -125,32 +125,8 @@ Client::~Client()
         //delete the connections differently than in deleteConnections()
         //deleteLater() seems to cause destruction order issues
-        QValueList<Connection*> connList = d->connections.getConnections();
-        QValueList<Connection*>::iterator it = connList.begin();
-        d->connections.removeAllConnections();
-        while ( it != connList.end() )
-        {
-                Connection* c = *it;
-                it = connList.remove( it );
-                delete c;
-        }
-        
         delete d->ssiManager;
         delete d;
 }
 
-void Client::deleteConnections()
-{
-//      kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Deleting " << d->connections.count() << " connections" << endl;
-        QValueList<Connection*> list = d->connections.getConnections();
-        QValueList<Connection*>::iterator it = list.begin();
-        d->connections.removeAllConnections();
-        while ( it != list.end() )
-        {
-                Connection* c = *it;
-                it = list.remove( it );
-                c->deleteLater();
-        }
-}
-
 void Client::connectToServer( Connection *c, const QString& server, bool auth )
 {
@@ -184,5 +160,4 @@ void Client::close()
         d->active = false;
 //      kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Closing " << d->connections.count() << " connections" << endl;
-        deleteConnections();
         //these are based on a connection. delete them.
         delete d->errorTask;
@@ -207,4 +182,5 @@ void Client::close()
 //      kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Clearing our internal SSI list" << endl;
         d->ssiManager->clear();
+        d->connections.removeAllConnections();
 }
 

--- kdenetwork/kopete/protocols/oscar/liboscar/client.h  #1.11:1.12
@@ -382,6 +382,4 @@ protected slots:
 
 private:
-        /** Delete the connections */
-        void deleteConnections();
         
         /** Initialize some static tasks */

--- kdenetwork/kopete/protocols/oscar/liboscar/connectionlist.cpp  #1.2:1.3
@@ -35,7 +35,4 @@ ConnectionList::ConnectionList()
 ConnectionList::~ConnectionList()
 {
-        delete m_bosConnection;
-        delete m_authConnection;
-        delete m_iconConnection;
 }
 
@@ -57,4 +54,7 @@ QValueList<Connection*> ConnectionList::
 void ConnectionList::removeAllConnections()
 {
+        delete m_authConnection;
+        delete m_bosConnection;
+        delete m_iconConnection;
         m_bosConnection = 0;
         m_authConnection = 0;
Comment 11 Matt Rogers 2005-04-02 23:51:42 UTC
*** Bug 103053 has been marked as a duplicate of this bug. ***
Comment 12 Matt Rogers 2005-04-03 00:55:53 UTC
*** Bug 102439 has been marked as a duplicate of this bug. ***
Comment 13 Leo Savernik 2005-04-03 17:17:30 UTC
First, thanks for this workaround.

Second, does this fix mean I'll get a nasty popup window telling me that kopete lost its internet connection? I don't want that, I *know* that I lost the connection (as I disconnected it intentionally).

Can't it simply go offline silently like it did in KDE 3.3 or earlier?
Comment 14 Matt Rogers 2005-04-03 17:41:25 UTC
right now, you should get a popup, but only one popup. I'll find a way to just make it silently disconnect depending on the possible error message that i get.
Comment 15 Nedim Cholich 2005-04-18 22:08:14 UTC
After upgrading to 3.4.0 I think I'm seeing the same thing. I use my laptop at work where they are blocking ports for aim and icq (but not msn). At home kopete works fine but in the office when I start it I get endless stream of: 
"QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()"
in console log and neverending popups:
"An unknown error has occurred and the connection has been closed"
Which are impossible to get rid of.
Comment 16 Matt Rogers 2005-04-19 00:30:15 UTC
all the annoying popups should be fixed for KDE 3.4.1. Leo, I've added a separate item to my TODO list to make it silently go offline if detected. If you feel compelled to, you can open a wish list item. :)
Comment 17 Leo Savernik 2005-04-19 12:34:09 UTC
Am Dienstag, 19. April 2005 00:30 schrieb Matt Rogers:
> it silently go offline if detected. If you feel compelled to, you can open
> a wish list item. :):)


Done :-) Bug 104202.
Comment 18 Matt Rogers 2005-04-22 15:28:52 UTC
*** Bug 104372 has been marked as a duplicate of this bug. ***
Comment 19 Matt Rogers 2005-04-26 03:30:19 UTC
*** Bug 104561 has been marked as a duplicate of this bug. ***
Comment 20 Jason Powers 2005-04-26 07:29:06 UTC
I don't exactly see how Bug 104561 is a duplicate of this bug.  I have seen this issue in older Kopete installs, but not thus far in the 0.10 in kubuntu hoary.  Bug 104561 seems to be a different and unrelated issue.  
Comment 21 Matt Rogers 2005-04-26 17:57:54 UTC
*** Bug 103434 has been marked as a duplicate of this bug. ***