Version: (using KDE KDE 3.5.6) Installed from: Compiled From Sources Compiler: GCC 4.1.2 OS: Linux Something in KDE makes passive grabs, which never get released. When the number of grabs gets higher, it starts to slow down the X server. I need a few days of uptime until the slowdown is obvious; after two weeks everything is very sluggish. For example, changing between applications takes 1-2 seconds, and keyboard repeat rate drops to 15-20 chars/sec instead of my normal 30 chars/sec. When investigating the problem, I decided to kill processes one by one. At that time I had 18 days of KDE uptime. When I killed kded, the X server hung *totally* for 45 minutes; according to gdb it was releasing grabs. After releasing all the grabs, everything was snappy again. That is, I didn't need to restart the X server. With lower uptimes (about one week), I have noticed that logging out from KDE has taken up to five minutes. The reason was very probably the same as above, but the number of grabs hadn't grown so large yet. So far I don't know what exactly is making those grabs. I assigned this bug to kded, because it was kded that was holding the grabs. There is some additional information in Freedesktop.org's Bugzilla <https://bugs.freedesktop.org/show_bug.cgi?id=2738>. While I think that KDE shouldn't do massive amount of duplicate grabs, I think that X server shouldn't accept so many duplicate grabs either. This bug is may be related to KDE bug #117169, which now has a working work-around. However, the exact problem behind that tough bug wasn't found, but it had something to do with grabs.
I think this should be fixed in X. The X docs don't seem to say anything about repeated grabs, but e.g. the description of XUngrabKey() IMHO implies that they should not be stacked, i.e. that if such a grab already exists the next one should be a no-op and the very first ungrab should release it. Therefore I think the second patch in the x.org bugreport is correct. If nobody does anything about the x.org bugreport I suggest mailing the xorg@lists.freedesktop.org mailing list.
*** This bug has been confirmed by popular vote. ***
I got no reply to my post <http://lists.freedesktop.org/archives/xorg/2007-May/025054.html> but on #xorg-devel@Freenode I was told that the X11 client should be fixed. Currently it seems that the actual behavior (stacking vs. erasing the old grab) won't change. Maybe they will change from growing the linked list to reference counting, which will make the server suffer a lot less from large amount of grabs. Everyone agreed that the documentation is ambiguous, so relying on repeated grabs is a bad idea in any case.
It seems I've talked somebody from X.org into the fact that this should be fixed in X.org after all. Please test the patch from the linked bugreport if possible.
I will test the patch. Unfortunately I usually don't have long uptimes in the summer, and this bug isn't obvious without at least one week uptime. It may take some time before I'm able to confirm that the patch works. It looks good to me though (definitely better than my patches).
I just had 22 days of uptime, and things were still running smoothly. Also, logging out didn't take more time than usually. Thus, this bug seems to be fixed now. Thank you.