apps-wont-open-due-to-maximum-clients-reached-error

Bug #263211 reported by Daniel Holm on 2008-08-31
52
This bug affects 4 people
Affects Status Importance Assigned to Milestone
KDE 4 Backports
Undecided
Unassigned
gnome-desktop
Fix Released
Medium
gnome-screensaver (Ubuntu)
High
Ubuntu Desktop Bugs
Nominated for Lucid by Alloc
Intrepid
High
Ubuntu Desktop Bugs

Bug Description

I start my computer, sit by it and work, play some game, or so. Then I go to bed, start a movie and fall asleep. When I wake up I get this message for every app I'm trying to start:
This is from update-manager:

Maximum number of clients reached/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py:72: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
Maximum number of clients reachedTraceback (most recent call last):
  File "/usr/bin/update-manager", line 44, in <module>
    gtk.init_check()
RuntimeError: could not open display

tessonec (tessonec) wrote :

I can confirm this bug.

Running kde 4.1.1

[code]
[~] xlsclients | wc -l
Maximum number of clients reachedxlsclients: unable to open display ":0.0"
[~] xwininfo -root -children
Maximum number of clients reachedxwininfo: unable to open display ':0.0'
[/code]

I am willingful to add more information, but I do not know exactly what to do.

tessonec (tessonec) wrote :

I found a workaround in Hardy. It seems that the gsim-applet was respawning a lot, and it decreased (also) system performance (I was blaming the build of KDE 4.1.1

Jelle De Loecker (skerit) wrote :

I'm running into the same problem ever since I upgraded to intrepid.

It's not gsim-applet, because I don't have kde 4 installed.

Matthew East (mdke) wrote :

I also get this error in current intrepid. I think it is likely to be an xorg problem, so I'll assign that package for now. If I'm wrong, it can be reassigned.

Aloys (aloys-baillet) wrote :

Same error, after a day of usage, no app will ever start again, have to restart X to get it to work. From an already running shell I get the following:
Maximum number of clients reachedError: cannot open display: :0.0
This started to appear after I upgraded to intrepid, happens in Gnome.

Roland Dreier (roland.dreier) wrote :

I see this to on an Intrepid system (running gnome, not kde). After a while, no more X clients can be started, and I get the error 'Maximum number of clients reachedxlsclients: unable to open display ":0.0"'

However if I close some client, then I am able to start another client. And apparently X doesn't see very many clients, eg with a system in this state that is only able to open one more client, I get:

$ xlsclients
roland-conroe x-session-manager
roland-conroe gnome-settings-daemon
roland-conroe gtk-window-decorator
roland-conroe gnome-screensaver
roland-conroe gnome-panel
roland-conroe nautilus
roland-conroe update-notifier
roland-conroe gnome-power-manager
roland-conroe nm-applet
roland-conroe evolution-alarm-notify
roland-conroe applet.py
roland-conroe evolution-exchange-storage
roland-conroe trashapplet
roland-conroe multiload-applet-2
roland-conroe music-applet
roland-conroe gnome-terminal
roland-conroe notification-daemon

My guess would be some leak in the X server that doesn't fully free up clients when they exit.

Daniel Hobe (hobe) wrote :

xrestop shows the problem very well. Over time there are a lot of clients with an id of '<unknown>' eventually there are enough of them to hit the 255 client limit.

I haven't been able to track down the responsible bit of software yet, but my environment really only has gnome + firefox (with more than a few plugins installed).

Changed in kde4-backports:
status: New → Invalid
Daniel Hobe (hobe) wrote :

Here's how to recreate the problem:

When running gnome (you may need to install the xrestop package):
xrestop -b -m 1 | grep '<unknown>' | wc -l

Then trigger the screensaver:
gnome-screensaver-command -a

Then run the xrestop command again. I see the number increase by 2 every time the screensaver starts. These windows never go away and eventually take up all the slots. It doesn't seem to matter which screensaver module you use. I don't see this when I trigger xscreensaver.

Roland Dreier (roland.dreier) wrote :

Yes, I've been doing some debugging too, and in my setup gnome-screensaver is the culprit as well. Specifically it calls gnome_bg_create_pixmap() (from libgnome-desktop) with root == TRUE, which ends up creating a new connection to the X server, calling XSetCloseDownMode() to change to RetainPermanent, and then disconnecting. And in that case the X server keeps the client data structures around forever.

I'm now reading through the gnome-screensaver code to figure out why it calls gnome_bg_create_pixmap() repeatedly.

RichardMBoos (richboos) wrote :

I can confirm this running Intrepid and Gnome. Problem arises after the computer is left on for 1-2 days.

Roland Dreier (roland.dreier) wrote :

So I've analyzed the gnome-screensaver/gnome_bg_create_pixmap() problem a little further. I believe this is (arguably) a bug in libgnome-desktop: gnome_bg_create_pixmap() creates an X client with CloseDownMode set to RetainPermanent, and uses this client to create a new pixmap, which it then passes to gdk_pixmap_foreign_new().

However, when the ref count on this gdk pixmap drops to zero, gdk does not actually free the pixmap, because it has the is_foreign flag set (since it was created with gdk_pixmap_foreign_new()). So the dummy X client from libgnome-desktop is left with one pixmap forever. The problem is that libgnome-desktop just forgets about the pixmap it creates and passes to gdk_pixmap_foreign_new() as soon as gnome_bg_create_pixmap() returns, so it leaks.

However I'm not sure what a good fix for this is yet.

Dag Stenstad (dag-stenstad) wrote :

As Daniel Hobe has mentioned, I also get a lot of <unknown> entries in xrestop. Attached is the output after 1 workday.

Timo Aaltonen (tjaalton) on 2008-10-09
Changed in xorg:
importance: Undecided → High
Sebastien Bacher (seb128) wrote :

the issue is an upstream one, could somebody send it to bugzilla.gnome.org?

Roland Dreier (roland.dreier) wrote :

I'll file it on bugzilla.gnome.org.

Changed in gnome-desktop:
status: Unknown → New
Sebastien Bacher (seb128) wrote :

Thank you for sending the bug to GNOME

Changed in gnome-desktop:
assignee: nobody → desktop-bugs
status: Confirmed → Triaged
Kees Cook (kees) on 2008-10-10
Changed in gnome-desktop:
milestone: none → ubuntu-8.10

It seems that the number of clients consumed by each GNOME ScreenSaver activation is equal to the number of monitors you have. Those with more than one monitor are getting bitten by this somewhat quicker!

A little digging gives the following:

libgnome-desktop/gnome-bg.c - both the gnome_bg_create_pixmap() and make_root_pixmap() function it calls are largely unchanged since this code was added - however that was only in November 2007 - previously libegg was used

The change to use this function seems to have landed in gnome-screensaver in rev 1434, which is since hardy - however this isn't exactly a one line change! :-(

That commit has the following ChangeLog entry:

 * configure.ac:
 * src/Makefile.am:
 * src/debug-screensaver.sh:
 * src/gs-manager.c (gs_manager_init),
 (apply_background_prefs_to_window), (manager_show_window):
 * src/gs-window-x11.c (gs_window_set_background_pixmap),
 (gs_window_clear_to_background_pixmap), (gs_window_clear),
 (spawn_on_window), (popup_dialog_idle), (gs_window_init):
 * src/gs-window.h:
 Add support for showing the desktop background behind the
 unlock dialog. Add dep on gnome-desktop and
 pull in libbackground as an svn:external.
 Still to-do:
 1. add bg_preferences_load_defaults to pull from
 system defaults instead of user settings
 2. process bg changes
 3. fix clearing child windows to the pixmap

An obvious patch appears to be:

--- src/gs-manager.c.orig 2008-10-10 18:28:13.000000000 +0100
+++ src/gs-manager.c 2008-10-10 18:28:21.000000000 +0100
@@ -1281,9 +1281,9 @@
         pixmap = gnome_bg_create_pixmap (manager->priv->bg,
                                          gs_window_get_gdk_window (window),
                                          width,
                                          height,
- TRUE);
+ FALSE);
         gs_window_set_background_pixmap (window, pixmap);
         g_object_unref (pixmap);
 }

This will make gnome_bg_create_pixmap just call gdk_pixmap_new() passing in the window, width and height; instead of calling make_root_pixmap() which makes an X root pixmap.

gnome-screensaver (2.24.0-0ubuntu2) intrepid; urgency=low

  * debian/patches:06_dont-leak-root-windows.patch:
    - Don't create the GNOME background pixmap with root=TRUE, since that
      results in a permanent client connection and unfreeable foreign image;
      the leak of these causes you to quickly run out of X clients, especially
      on multiple monitors. LP: #263211.

Strange, this wasn't closed automatically

Changed in gnome-desktop:
status: Triaged → Fix Released
Sebastien Bacher (seb128) wrote :

the bug was not closed by the changelog because the component were different

Changed in gnome-desktop:
status: New → Fix Released
Matthew Carpenter (matt-eisgr) wrote :

Where is the KDE version of this? How many of these bugs can there be, since it just started impacting me within the past year... and I don't run Gnome... I run KDE starting with Kubuntu-base-install.

And how do I know which bug is impacting me, since there seem to be many which have the same symptoms...

Brion Swanson (brions) wrote :

You might start by disabling your screen saver (though you can leave your power saving features on). Even before this bug patch was committed, I disabled the screen saver and stopped experiencing the problem.

This is just a helpful suggestion, not a verified solution by any means.

On Thursday 30 October 2008, Brion Swanson wrote:
> You might start by disabling your screen saver (though you can leave
> your power saving features on). Even before this bug patch was
> committed, I disabled the screen saver and stopped experiencing the
> problem.
>
> This is just a helpful suggestion, not a verified solution by any means.

I'll try it.... but I rely on my screensave to save me from "oopses". Yes, I
realize cold-boot attacks render screen-savers less secure than otherwise
thought to be. But still, it provides some level of added safety.

What I want to know is why all these troubles started after upgrading. (I
think to Hardy??? I've lost track they've been plaguing me so long now).
It's become a part of life to close down valid windows. I never knew there
*was* a limit to the number of X clients a user could have running at once.

Point of interest, I run with two users logged in a lot (ie. :7 and :8 are
both setup to have login screens). When I hit the max on one, going to the
other allows me to work... as the other user of course. Yes, I have multiple
personality disorder and need two different users. long story.

Matthew Carpenter (matt-eisgr) wrote :

In KDE, the knetworkmanager seems to increment the count of
     xwininfo -root -children
every time you interact with the rt-click menu.

At first it raises the count a few... and when you make the menu disappear, it's always one greater that the count before...

Should this be added as a new bug? or have them plug into this bug?

Matthew Carpenter (matt-eisgr) wrote :

This increase in numbers is consistent, and was caused simply by Right-Clicking on knetworkmanager and hitting escape... over and over again.

1425
1425
1425
1425
1426
1430
1434
1438
1442
1444
1448
1453
1458
1466
1472
1474
1474
1474

It seems that "Maximum clients reached" is more a symptom of it's own bug classification, which is indicative of any application not managing its X resources carefully.

All applications (in all distributions) should undergo testing to prove they have no "X resource leakage" so to speak. Clearly writing a desktop systray-applet that misses reclaiming an X window here and there doesn't seem like that big a deal.... but apparently many apps are causing a big problem.

How do we proceed???

Chris Purves (chris-northfolk) wrote :

Are there any tips on how to troubleshoot this problem and isolate which application is not releasing resources. I am running kubuntu intrepid and when running xrestop see that the number of clients goes to 210 on startup.

Matthew Carpenter (matt-eisgr) wrote :

On Saturday 22 November 2008, Chris Purves wrote:
> Are there any tips on how to troubleshoot this problem and isolate which
> application is not releasing resources. I am running kubuntu intrepid
> and when running xrestop see that the number of clients goes to 210 on
> startup.

I find that it's a hit or miss thing. I've not found an easy way to track
down what is causing the issue. The only thing I've been able to do is
use "xwininfo -root -children" (normally piped to wc -l) and "ps aux", and
start killing X apps owned by the current user and checking for large changes
to xwininfo. That's also how I found the fact that Koqueror processes were
not dying when I closed them.

I normally idle around 900 xclient listings at startup and I start having
problems around 2500-3000. Yes, I make use of many of KDE's utilities.

Chris Purves (chris-northfolk) wrote :

I did try something similar, but for me all the extra clients were opened shortly after login, so not enough time to kill processes before they would spawn multiple instances. I found that I had 183 instances of python running after logging in to KDE. Removing as many startup apps as I could did not identify the problem app, but I found that creating and logging in to a new account didn't exhibit the multiple instances of python and xclients.

My solution was to rename ~/.kde and allow it to be regenerated. This has resolved the problem for me.

Matthew Carpenter (matt-eisgr) wrote :

On Saturday 22 November 2008, Chris Purves wrote:
> I did try something similar, but for me all the extra clients were
> opened shortly after login, so not enough time to kill processes before
> they would spawn multiple instances. I found that I had 183 instances
> of python running after logging in to KDE. Removing as many startup
> apps as I could did not identify the problem app, but I found that
> creating and logging in to a new account didn't exhibit the multiple
> instances of python and xclients.
>
> My solution was to rename ~/.kde and allow it to be regenerated. This
> has resolved the problem for me.

Interesting. I wonder if you were running into a guidance-power-manager bug
in handling old configurations... That's the primary thing I know of that
uses Python after you log in. It's the tool which shows your battery power
as well as allows you to suspend/hibernate and change power consumption
profiles.

I may try that. It's a bit akin to reinstalling the os on Windows, without
all the hastel ;)

Matt

Henri Cook (henricook) wrote :

I believe I have this problem in Intrepid, new things stop spawning - which also means if I go to system -> shutdown a box appears but all the buttons (restart/shutdown/log out etc.) can't appear - makes the system largely unusable.

w.r.t. the workaround suggested, I have at the moment about 10 unknown resources in xrestop, how can I relate them back to a process? e.g. how do i know what's causing them? I've tried killing gnome-screensaver which I suspect is the cause but the unknown resources remain?

Thanks,

H

Henri Cook (henricook) wrote :

This report says fix released - where is this fix? How can i get it? I've now got this problem on my new laptop, it started as soon as I plugged it into a second screen this afternoon - my main three screen PC uses nvidia, this uses ATI but i've only ever had these symptoms when using more than one screen - can someone tell us what's going on?

This problem has started to affect me today.
I'm using a backport of KDE 4.4.1 on Karmic.
Applications in use are Skype, Jungledisk, Chromium, Firefox, Terminal and Dolphin.

All the sudden Dolphin can't open any of my files and if I try from the terminal I'm giving the message described in this bug.

Timo Aaltonen (tjaalton) wrote :

interfasys: something in kde is leaking/creating client connections, and the limit (256) is reached. File a bug against kde.

Florent Viard (fviard) wrote :

Hi,
I'm also affected by this bug with ubuntu 9.10.
Maybe it goes faster to trigger in my case as I have 2 monitors.

It could be related to kdelibs as i installed them to be able to use Kate.
And I noticed that kate used 1 client connection for each file opened as a tab in my kate window.
Closing a kate with 3 tabs reduced my xlsclients | wc -l from 44 to 38 removing 4 kates and 2 knotify4.

Isn't there a tweak to change xlsclients max value ? Because 56 looks really small regarding all the mandatories applications in my ubuntu system:

user-desktop kate
user-desktop gnome-session
user-desktop gnome-settings-daemon
user-desktop seahorse-daemon
user-desktop notify-osd
user-desktop gnome-panel
user-desktop nautilus
user-desktop trashapplet
user-desktop update-notifier
user-desktop gdu-notification-daemon
user-desktop tracker-applet
user-desktop gnome-volume-control-applet
user-desktop gnome-power-manager
user-desktop nm-applet
user-desktop bluetooth-applet
user-desktop polkit-gnome-authentication-agent-1
user-desktop gtk-window-decorator
user-desktop indicator-applet-session
user-desktop indicator-applet
user-desktop evolution-alarm-notify
user-desktop applet.py
user-desktop gstm
user-desktop thunderbird-bin
user-desktop xchat
user-desktop gnome-terminal
user-desktop putty
user-desktop firefox-bin
user-desktop '<unknown>'
user-desktop kded4
user-desktop kded4
user-desktop '<unknown>'
user-desktop knotify4
user-desktop knotify4
user-desktop '<unknown>'
user-desktop kwalletd
user-desktop kwalletd
user-desktop gedit
user-desktop LaCieNetworkAssistant
user-desktop grdc
user-desktop gnome-screensaver
user-desktop '<unknown>'
user-desktop kate
user-desktop kate
user-desktop kate
user-desktop kate

Florent Viard (fviard) wrote :
Download full text (5.5 KiB)

It looks like that it is not really related to the kdelibs because even not using any kde apps after a fresh start the problem occured. Maybe the root cause is firefox cf:
http://www.karakas-online.de/forum/viewtopic.php?t=10494

I have a lot of :
     0x401417d "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x40138d3 "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x40138d0 "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x40138ca "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x40138c7 "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x40138c4 "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x401376f "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x40118ea "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x401179b "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
     0x4011793 "Firefox": ("Popup" "Namoroka") 200x200+0+0 +0+0
in my :
xwininfo -root -children

but there is also 10s of lines related to the applets:
     0x3c00001 "applet.py": ("applet.py" "Applet.py") 10x10+10+10 +10+10
     0x1a001d8 (has no name): () 16x36+7+-13 +7+-13
     0x3000003 "evolution-exchange-storage": () 10x10+-100+-100 +-100+-100
     0x3000001 "evolution-exchange-storage": ("evolution-exchange-storage" "Evolution-exchange-storage") 10x10+10+10 +10+10
     0x1a001d0 (has no name): () 16x36+7+-13 +7+-13
     0x2000001 "evolution-alarm-notify": ("evolution-alarm-notify" "Evolution-alarm-notify") 10x10+10+10 +10+10
     0x1a001cb (has no name): () 16x36+7+-13 +7+-13
     0x1e000b5 "File Manager": () 10x10+-100+-100 +-100+-100
     0x1c000a4 "Tableau de bord": () 10x10+-100+-100 +-100+-100
     0x3800003 "indicator-applet-session": () 10x10+-100+-100 +-100+-100
     0x1a00016 (has no name): () 2x1020+2558+2 +2558+2
     0x1a00015 (has no name): () 2x1020+0+2 +0+2
     0x3800001 "indicator-applet-session": ("indicator-applet-session" "Indicator-applet-session") 10x10+10+10 +10+10
     0x1a00138 (has no name): () 16x36+7+-13 +7+-13
     0x1e00003 "File Manager": () 10x10+-100+-100 +-100+-100
     0x2600180 (has no name): () 1x1+-100+-100 +-100+-100
     0x2600046 "gtk-window-decorator": ("gtk-window-decorator" "Gtk-window-decorator") 1x1+-100+-100 +-100+-100
     0x2a00003 "gnome-screensaver": () 10x10+-100+-100 +-100+-100
     0x1c00035 (has no name): () 10x10+0+0 +0+0
     0x1a0011a (has no name): () 16x36+-3+-23 +-3+-23
     0x2600003 (has no name): () 1x1+-100+-100 +-100+-100
     0x2600001 "gtk-window-decorator": ("gtk-window-decorator" "Gtk-window-decorator") 10x10+10+10 +10+10
     0x1a00118 (has no name): () 16x36+7+-13 +7+-13
     0x3600001 "polkit-gnome-authentication-agent-1": ("polkit-gnome-authentication-agent-1" "Polkit-gnome-authentication-agent-1") 10x10+10+10 +10+10
     0x1a00117 (has no name): () 16x36+7+-13 +7+-13
     0x2a00001 "gnome-screensaver": ("gnome-screensaver" "Gnome-screensaver") 10x10+10+10 +10+10
     0x1a00116 (has no name): () 16x36+7+-13 +7+-13
     0x2400001 "Tracker": ("tracker-applet" "Tracker-applet") 10x10+10+10 +10+10
     0x1a00114 (has no name): () 16x36+7+-13 +7+-13
     0x3400001 "gnome-power-mana...

Read more...

djlj (spam-vsevjednom) wrote :

Hello, I got a same problem after update from Karmic to Lucid.

Maximum number of clients reachedxwininfo: unable to open display ':0.0'

Alloc (christian-illy) wrote :

Not fixed in Ubuntu 10.04 Lucid. Is there any way (besides disabling the screensaver) to avoid this? Like manually removing the pixmaps/<unknown>'s from X?

Changed in gnome-screensaver (Ubuntu Intrepid):
status: Fix Released → Incomplete
status: Incomplete → Fix Released
Changed in gnome-screensaver (Ubuntu):
status: Fix Released → Incomplete
Chris Coulson (chrisccoulson) wrote :

Please don't reopen old bugs. This particular bug was fixed a long time ago, and it's most likely that you are experiencing a completely unrelated issue

Changed in gnome-screensaver (Ubuntu):
status: Incomplete → Fix Released
Sam Malone (sam8ps) on 2010-07-10
Changed in gnome-screensaver (Ubuntu):
status: Fix Released → New
Changed in gnome-screensaver (Ubuntu):
status: New → Fix Released
Changed in gnome-desktop:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.