Wednesday, February 23, 2011

X11: Maximum number of clients reached

Lately, i am having a strange bug on my desktop system. I can't open any more application and it would close instantly. I didn't change anything on the system, so the application is actually working just fine, but somehow there's something blocking it.

So i tried to run the application from Konsole to see what really happened (it's one of the most simple thing to do if you want to debug a non-working application). I tried to run kate (just an example) and i got this as a return:
Maximum number of clients reached kate: cannot connect to X server :0

From the error message i got, i started to find out some reason on Google and it turns out that XOrg has a configuration to set up the maximum client that is allowed to connect to the server and the default in 1.9.4 (the one i used in -Current) is 256. You can check it by running this command:
cat /usr/include/xorg/misc.h | grep MAXCLIENTS

When i checked how many sockets that XOrg has opened, i was surprised since XOrg opened a lot of sockets. Use lsof -p `pidof X` | wc -l as root and i got around 321 (the number may vary). It has surpassed the maximum number limit defined by XOrg. That's why i can't launch any application at all that requires GUI.

Logging out KDE would temporarily fixed the problem, but it's not the ideal solution. Robby thought there's something in KDE is buggy, but he has no idea on the real solution.

If you have any workaround, please share it on LQ. For temporary fix, you can increase the number in MAXCLIENTS definition

Update (16 March 2011): This problem has been solved at Slackware-Current tree. The culprit is the old, obsolete guidance-power-manager package which was included in Slackware 13.1. Please remove this package and you will be fine. The drawback of this is that you might lost some information about battery power. Just use KDE's battery monitor to track your batteries. I should have mentioned this update earlier. Sorry for that.