Bug 229078 - kleopatra opens handles but never closes them causing windows to run out of handles
Summary: kleopatra opens handles but never closes them causing windows to run out of h...
Status: RESOLVED FIXED
Alias: None
Product: kleopatra
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: HI normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 247778 255311 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-03-01 23:18 UTC by kde
Modified: 2013-05-08 08:35 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Showing 8131 handles open by Kleopatra (186.25 KB, image/jpeg)
2011-01-11 07:20 UTC, Roderick
Details
Kleopatra 2.1.0 handles after 1.5 hours (161.35 KB, image/jpeg)
2011-01-11 08:44 UTC, Roderick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kde 2010-03-01 23:18:06 UTC
Version:           2.0.13-svn1084205 (2010-02-02) (using 4.1.4, compiled sources)
Compiler:          i586-mingw32msvc-gcc
OS:                Microsoft Windows (i686) release 5.1 (XP Professional)

Kleopatra is constantly opening handles under winxp.  The longer the process runs the more handles are open until finally windows refuses to open more sockets.  On my system that takes roughly 5 hours. 

Using process explorer I see 4000 handles open after running only an hour or so.  Looking at the handles tab I see An "Event" Handle followed by File Handle "\Device\Afd" followed by File Handle "\Device\Tcp".  Over and over and over again.  

In Process Monitor I see it doing:
TCP Reconnect localhost:1330->localhost:1260 
TCP Reconnect localhost:1330->localhost:1260 
TCP Disconnect localhost:1330->localhost:1260

2 reconnects, 1 disconnect.

Killing Kleopatra returns the handles to the pool and makes the system usable again.
Comment 1 Joakim Wallman 2010-08-10 17:00:21 UTC
Since this bug is difficult to track back to Kleopatra and it gives severe problems in Windows it should get highest priority.
I had to restart my computer several times a day before I discovered that this problem was related to Kleopatra.
I saw that the Handles went down since PuTTY reported "Network error: no buffer space available" and found the bug at this page:
http://serverfault.com/questions/131935/network-error-no-buffer-space-available
Comment 2 bios01 2010-08-28 11:20:03 UTC
Can confirm this bug with Kleopatra version 2.0.14-svn1098530 (2010-03-03)
under Windows XP Professional SP2 & SP3.

Kleopatra opening about every 3 seconds a "\Device\Tcp" Handle and a "\Device\Afd\Endpoint" Handle but only destroys the Afd\Endpoint.

After some hours all network communications (ssh, www, etc) are unusable, but ICMP Echo's still work.

Closing only Kleopatra and therefor destroying all open handles get the network communication back.
Comment 3 Joakim Wallman 2010-09-13 22:32:29 UTC
Can confirm the same behaviour in Kleopatra version 2.1.0-svn1167864 included with gpg4win 2.1.0 Beta 1
Comment 4 Roderick 2010-12-15 07:10:25 UTC
Confirming same problem - also using Kleopatra v2.0.14-svn1098530 with Gpg4win V2.0.4. Can somebody please fix or at least comment on this for us? It's a pain to restart Kleopatra everyday... Thanks!
Comment 5 Roderick 2010-12-15 07:24:30 UTC
(In reply to comment #4)
> Confirming same problem - also using Kleopatra v2.0.14-svn1098530 with Gpg4win
> V2.0.4. Can somebody please fix or at least comment on this for us? It's a pain
> to restart Kleopatra everyday... Thanks!

PS I'm using Windows XP SP3 with Outlook 2007.
Comment 6 Emanuel Schütze 2010-12-21 16:38:52 UTC
Any news? Seems to be a critical problem in Gpg4win.
Comment 7 Ville Ollikainen 2011-01-03 08:30:36 UTC
I also confirm this annoying bug:
- Kleopatra Version 2.0.14-svn1098530 (2010-03-03)
- Gpg4win 2.0.4
- WinXP Pro, SP3
- Office Outlook 2003, SP3

Whenever Kleopatra is running, it runs out of handles within a day or two. All network connections seem to die, but get back after restarting Kleopatra.
Comment 8 Emanuel Schütze 2011-01-10 15:16:18 UTC
Sorry, but I can't reproduce this issue. 
My test on Windows XP SP3:
- Install Gpg4win 2.1.0-rc1
- Run Kleopatra (v2.1.0-svn1192835)
- Import OpenPGP certificate
- Wait more than 3 days...

Kleopatra is already running. Kleopatra and internet connections works.
Logging with process monitor (v2.93) shows every 2 seconds network traffic between kleoatra and gpg-agent. After some hours process monitor crashed - maybe to much data?

Can anybody try to reproduce this issue with gpg4win-2.1.0-rc1?
Comment 9 Roderick 2011-01-11 07:20:33 UTC
Created attachment 55848 [details]
Showing 8131 handles open by Kleopatra
Comment 10 Roderick 2011-01-11 07:35:03 UTC
Hi all, problem still exists using gpg4win-2.1.0-rc1:

Windows XP SP3 + Office 2007
- Upgrade v2.0.4 to Gpg4win 2.1.0-rc1
- Run Kleopatra (v2.1.0-svn1192835) overnight
- This morning, Kleopatra crashed with 8131 handles open, email not working, Googletalk offline...

See attachment...
Thanks!
Comment 11 Roderick 2011-01-11 08:44:25 UTC
Created attachment 55853 [details]
Kleopatra 2.1.0 handles after 1.5 hours

Kleopatra properties in Process Explorer shows approx 2 handles being created and 1 handle destroyed continuously resulting in the pool eventually being consumed. Note: this is as per the original (first) log for this bug.
Comment 12 Ville Ollikainen 2011-01-12 07:56:41 UTC
> Can anybody try to reproduce this issue with gpg4win-2.1.0-rc1?

I updated to 2.1.0-svn1192835 (2010-11-04). It seems that the number of handles remains stable now.

(It's another issue, but the new Kleopatra crashes repeatedly.)
Comment 13 Emanuel Schütze 2011-01-12 09:27:39 UTC
Roderick,
I retested with Outlook 2007 on Win XP SP3 with Gpg4win 2.1.0-rc1:
- Run Outlook (Kleopatra starts)
- After ca. 9h Kleopatra and  Internet Connection works. Process Explorer shows 240 open Handles.
Note: I am testing with a fresh GNUPG-HOME dir. (Only one OpenPGP certificate imported.) Maybe you can do a restest with an emtpy GNUPGHOME or another machine? Do you use a smartcard reader?

Ville,
how many open handles Process Explorer shows after some hours? Do you started Kleopatra via Outlook 2003/2007? Do you have imported some OpenPGP/SMIME certificates?
(For your other issue: Can you reproduce the crash of Kleopatra? The best would be a step-by-step instruction.)
Comment 14 Ville Ollikainen 2011-01-12 10:01:34 UTC
> how many open handles Process Explorer shows after some hours? 

Currently there are two "kleopatra.exe" processes with 
 mem usage/vm size/paged pool/np pool/handles/threads 
as follows:

 1208K/288K/15K/1K/16/1
 36520K/16028K/185K/43K/352/10


> Do you started Kleopatra via Outlook 2003/2007? 

Good question... It's in the task bar. It may have been started by Outlook. 

It may have something (or have not anything) to do with the situation, that I have encrypted local Outlook folders, and Outlook requests password each time it is launched: launching Outlook takes more time than usual.


> Do you have imported some OpenPGP/SMIME certificates?

I have created one, and that's all in this PC.


> (For your other issue: Can you reproduce the crash of Kleopatra? The best 
> would be a step-by-step instruction.)

I created Bug 262918
Comment 15 Roderick 2011-01-14 10:47:25 UTC
A. not using smartcard reader
B. Environment var GNUPGHOME is not defined + no reference in registry - where is the default or how do I clear it?

Using gpg4win-2.1.0-rc1 -

1. Complete uninstall + removed references
2. Default install, skipped S/MIME configuration (not used)
3. Finish
4. Run Outlook = loads Kleopatra
(usually get this:
"The user interface server is not available or could not be started in time..." - clicked Retry (works))
5. My previous certificates were loaded by default
	a. 1 under "My Certificates"
	b. " same under Trusted
	c. 4 under Other certificates

Handles going up like crazy - already have 750 after < 1/2 hour.
Comment 16 Roderick 2011-01-14 11:31:30 UTC
Tried the following:
1. Shutdown Kleopatra and closed Outlook
2. Set "HKEY_LOCAL_MACHINE//SOFTWARE//GNU//GnuPG//HomeDir" to "C:\temp"
3. Restarted Outlook
4. Outlook froze on loading, Kleopatra not responding - using 50% of dual-core CPUs = almost 100% of one of my CPUs. No joy after waiting a few mins.
5. Killed Kleopatra process = Outlook loaded ok
6. Restarted Outlook - same problem.
7. Undef HomeDir. Tried environment variable GNUPGHOME = C:\Temp
8. Outlook loaded ok but Kleopatra still not responding and at 50% CPU... Outlook hangs when trying to open encrypted emails.
9. Restarted PC
10. Same problem
11. After killing Kleopatra, with Outlook still open tried running it manually
12. Seemed to load ok with 0 keys (expected - blank home dir)
[BUT the handles are still running away...]
13. Imported key
14. Tried to open encrypted email - not working
15. Tried to run certificate manager from Outlook - could not be loaded
16. Shutdown Kleopatra and close Outlook
17. Ah - I see, .conf files missing from temp home directory - copied from \Application Data\gnupg (assuming this is then the default home...)
18. Tried again. This time Outlook + Kleopatra started ok

0 keys in Kleopatra and the handles still keep on growing...
Comment 17 Roderick 2011-01-14 11:48:25 UTC
Hi Emanuel

Don't worry if this problem isn't reproducible - I'll live with it...
Just disabled the Gnupg addin and enable it when I need to send/receive encrypted mail (which fortunately isn't too often). But if there's a solution down the line I'll definitely use it!

Thanks for all your efforts!
Comment 18 Emanuel Schütze 2011-01-14 12:47:12 UTC
Now I can reproduce the problem with Gpg4win 2.1.0-rc1 and Outlook 2003 on Win XP SP3:
Open handles growing up to >8000 in <3h. Internet connection doesn't work. After restarting Kleopatra everything works fine.
(I started Kleopatra automatically via Outlook.)

Talked with Marc:
I comment out "app.startMonitoringSmartCard()" calls in kdepim/kleopatra/main.cpp and rebuild a new gpg4win installer for testing:
ftp://ftp.intevation.de/users/emanuel/gpg4win/gpg4win-2.1.0-rc1_kleofix20110113.exe
(sha1sum and signature in the same directory)

My tests are successfully with this new/patched installer. Can you confirm it?
Roderick, Ville: can you please test it? Thanks.

Note: With this patch the automatically smart card detection of Kleopatra no longer works. We are working for a solution.
Comment 19 Emanuel Schütze 2011-02-18 09:22:52 UTC
Issue resolved in gpg4win 2.1.0-rc2.

Not a kleopatra bug.
Fixed windows socket problem in Gpgme and libassuan and added new packages to gpg4win trunk with gpg4win svn rev1630.
Comment 20 Roderick 2011-03-03 10:36:14 UTC
Confirmed working in 2.1.0-rc2.

Thanks guys! Great work! Appreciated!
Comment 21 Andre Heinecke 2013-05-08 08:34:48 UTC
*** Bug 247778 has been marked as a duplicate of this bug. ***
Comment 22 Andre Heinecke 2013-05-08 08:35:48 UTC
*** Bug 255311 has been marked as a duplicate of this bug. ***