| Summary: | kio_imap4 eats randomly too much cpu | ||
|---|---|---|---|
| Product: | [Unmaintained] kio | Reporter: | LukasT <lukast.dev> |
| Component: | imap | Assignee: | kdepim bugs <pim-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | rdieter, tiposchi, tomastrnka, winter, x |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Fedora RPMs | ||
| OS: | Unspecified | ||
| Latest Commit: | Version Fixed In: | ||
| Sentry Crash Report: | |||
|
Description
LukasT
2009-08-13 14:53:06 UTC
I did observation and this bug appear almost everytime I close the Kontact with x button in the row and it is not minimized (as it should be) into systray but it close itself and then the kio_imap4 eats both cores. Happens to me when I resume my laptop from 'sleep'. But only happens maybe 20% of the time, so I haven't been able to figure out any sort of pattern. I theorize that kio_imap4 may be upset about sudden network disappearance during one of it's operations, but this is a wild guess and may not apply to the situation described by others. I had recently been hitting this bug few times a day and today I finally found time to investigate it.
kio_imap4 falls into an infinite loop if any connection error occurs during authentication (e.g. connection is suddenly lost). The backtrace looks like this:
#0 0x00007f86a8bdd91e in IMAP4Protocol::parseReadLine (this=0xdea4e0, buffer=<value optimized out>, relay=0)
at /usr/src/debug/kdepimlibs-4.3.4/kioslave/imap4/imap4.cpp:766
#1 0x00007f86a8c08ef2 in imapParser::parseLoop (this=0xdea510)
at /usr/src/debug/kdepimlibs-4.3.4/kioslave/imap4/imapparser.cpp:1725
#2 0x00007f86a8c0b863 in imapParser::clientAuthenticate (this=0xdea510, slave=<value optimized out>,
ai=<value optimized out>, aFQDN=<value optimized out>, aAuth=<value optimized out>, isSSL=<value optimized out>,
resultInfo=<value optimized out>) at /usr/src/debug/kdepimlibs-4.3.4/kioslave/imap4/imapparser.cpp:268
#3 0x00007f86a8be15fd in IMAP4Protocol::makeLogin (this=0xdea4e0)
at /usr/src/debug/kdepimlibs-4.3.4/kioslave/imap4/imap4.cpp:2133
When IMAP4Protocol::parseReadLine detects it's not connected, it returns false. This causes imapParser::parseLoop to return -1. However, imapParser::clientAuthenticate doesn't check for this and (using a while(true) loop) keeps retrying indefinitely.
This should be trivial to fix (properly check the return value of imapParser::parseLoop and bail out if -1). However, I do not currently have time to test the fix properly, so it will have to wait for a week or so...
Tomas, thanks!
Once we have a working patch I will ask the distros to push it out to their users.
Here's a possible patch for people to try
Index: /data/kde/trunk/KDE/kdepimlibs/kioslave/imap4/imapparser.cpp
===================================================================
--- /data/kde/trunk/KDE/kdepimlibs/kioslave/imap4/imapparser.cpp (revision 1070797)
+++ /data/kde/trunk/KDE/kdepimlibs/kioslave/imap4/imapparser.cpp (working copy)
@@ -265,9 +265,11 @@ imapParser::clientAuthenticate ( KIO::Sl
while ( true )
{
//read the next line
- while (parseLoop() == 0) {
+ int parseStat;
+ while ( ( parseStat = parseLoop() ) == 0) {
;
}
+ if ( parseStat < 0 ) break;
if ( cmd->isComplete() ) break;
if (!continuation.isEmpty())
Here is another, possibly better (untested) patch:
Index: imapparser.cpp
===================================================================
--- imapparser.cpp (revision 1071187)
+++ imapparser.cpp (working copy)
@@ -262,13 +262,12 @@ imapParser::clientAuthenticate ( KIO::Sl
}
cmd = sendCommand (CommandPtr(new imapCommand ("AUTHENTICATE", firstCommand.toLatin1())));
- while ( true )
- {
+ int pl = 0;
+ while ( pl != -1 && !cmd->isComplete () ) {
//read the next line
- while (parseLoop() == 0) {
+ while ( ( pl = parseLoop() ) == 0) {
;
}
- if ( cmd->isComplete() ) break;
if (!continuation.isEmpty())
{
SVN commit 1074158 by ttrnka: Properly check errors during authentication to avoid falling into an infinite loop. BUG:203715 M +3 -4 imapparser.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1074158 SVN commit 1074179 by winterz: backport SVN commit r1074158 by ttrnka: Properly check errors during authentication to avoid falling into an infinite loop. CCBUG:203715 M +3 -4 imapparser.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1074179 *** Bug 187077 has been marked as a duplicate of this bug. *** |