Bug 210774

Summary: Too many open files when accessing IMAP
Product: [Unmaintained] kmail Reporter: David Jander <djander>
Component: IMAPAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bjoern, gullevek, markus.duft, michaeld, rob, sean-kde, tniagcpm
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description David Jander 2009-10-16 12:05:51 UTC
Version:            (using KDE 4.3.2)
Compiler:          gcc (Ubuntu 4.4.1-4ubuntu7) 4.4.1 
OS:                Linux
Installed from:    Ubuntu Packages

When I configure an IMAP account that has many IMAP folders (1000 or more), kmail starts scanning all folders, and eventually starts displaying a storm of error messages complaining:
'Cannot open file "XXX": Too many open files'.

The bug apparently is triggered by a call to KDE_fopen() in line 128 of the file kmail/kmfoldermbox.cpp

For some reason a huge amount of control files is kept open (proportional to the amount of IMAP folders) eventually hitting ulimit.

If I increase the hard- and soft limits of open files per process (originally at 1024 on ubuntu), eventually kmail starts successfully, but I think kmail should never keep all those files open at the same time. It seems like a useless waste of resources, does not scale, and will cause problems (crashes) for users with large IMAP accounts.

I selected severity:bug for this issue because it is not a "crash" in the strictest sense of the word, but it has the same importance IMHO. Kmail is not usable on such accounts if you are not allowed to increase your ulimit values.
Comment 1 Clemens Schwaighofer 2009-11-05 08:17:23 UTC
I can confirm this bug with Debian/Testing packages (version 4.3.1-2).
Comment 2 steveb 2009-11-24 11:00:06 UTC
I can confirm this with: Kontact 4.3.2, KMail 1.12.2
(Installed from: kubuntu 9.10 i386 Packages)

The IMAP server has 1000+ folders, and KMail cannot complete the account setup process due to this problem.
Unfortunately, on such IMAP servers, KMail is now unusable.
Comment 3 Markus Duft 2010-02-16 15:14:48 UTC
i can confirm this: i have a really huge exchange server account which i'm trying to setup through imap. it makes kmail issue hundreds of error messages about too many open file. the only thing that helps is killing the process, restarting it, killing it again, etc. until all mails have been read once - it then seems to work...

actually i didn't want that one big huge folder in my local account setup, but kmail locked up with errors so fast that i was unable to change the folder subscriptions fast enough :(
Comment 4 Björn Ruberg 2010-03-06 21:53:09 UTC
Have seen this too
Comment 5 Björn Ruberg 2010-03-06 21:56:21 UTC

*** This bug has been marked as a duplicate of bug 160968 ***