Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm hitting a problem whereby X prevents processes from creating windows, uttering something like the following into ~/.xsession-errors:

cannot open display: :0.0
Maximum number of clients reached

Searching around there are lots of examples of people facing this problem, and sometimes people identify which program they are running is using up all the client slots. See e.g. LP 70872 (Firefox), LP 263211 (gnome-screensaver).

For what it's worth, I run gnome-terminal, thunderbird, chromium-browser, empathy, tomboy and virtualbox nearly all the time, on top of the normal stuff you get with the GNOME desktop, and occasionally some other bits and pieces.

However my question is not "which of my programs is causing this problem" but rather, how can one go about diagnosing this problem?

In the above (and other) bugs, forum reports, etc., a number of tools are suggested:

  • xlsclients - lists the client applications for the given display, but I don't think that corresponds to 'X clients'
  • xrestop - a top-style X resources tool, one row per X client. Lots of '' clients, not shown in xlsclients output
  • xwininfo -root -children lists X window objects

From what I can gather, the problem might not be too many clients at all, but rather resources kept around in the X server for clients who have long-since detached. But it would also appear that you cannot (easily?) relate X resources back to their client. Can one effectively diagnose this issue once it has started to occur, or is a tedious divide-and-conquer approach for the apps I run the only approach open to me?

Update Jan 2011: I think I have resolved this issue. For the benefit of anyone stumbling across this, nautilus and/or compiz or something in that chain of software was segfaulting due to a wallpaper I had. I had chosen an XML file as my wallpaper, which defined a rotating gallery of images. It was hand-made, but based on /usr/share/backgrounds/contest/background-1.xml or similar. Disabling the wallpaper and I have not had a crash since.

I'm not marking this as answered yet, since the actual specific problem was not my question, but how to diagnose it was. Unfortunately this was mostly trial-and-error which sucks.

share|improve this question
    
Have you checked the xrestop output? What do the first 3 lines tell you? How much memory/video memory do you have in the machine? –  jneves Oct 10 '10 at 9:25
add comment

3 Answers 3

Chromium/Chrome has some known issues which result in this error message. Do you use the Lastpass extension?

ref: http://www.ngohaibac.com/how-to-solve-maximum-number-of-clients-reached-gtk-warning-cannot-open-display-in-ubuntu-9-10-64-bit/

share|improve this answer
    
I do not use that extension. –  jmtd Oct 13 '10 at 22:51
    
Still worth testing the system with Chromium removed to see if it alleviates the problem. Not sure how you'd fix it once confirmed (short of removing Chromium, which I assume you'd want to avoid if possible). –  Jeremy Oct 14 '10 at 0:55
    
As a last-ditch effort I could try that. The same applies to other software that google points the finger at, e.g., gnome-screensaver. The trouble is, I use chromium pretty heavily, so removing it, even temporarily, is quite a blow to my working practices. What I would really like to do is prove it was responsible without having to stop using it. –  jmtd Nov 4 '10 at 13:51
add comment

I have the same question, because I think this issue is significant for anyone who does not reboot their computer often. One thing I've really liked about UNIX/Linux/Ubuntu over the years is that I can reliably run my laptop for months without rebooting (suspending only), except when I install a new kernel. Since upgrading to the "suite" that is Maverick (Ubuntu 10.10), I've encountered this and can only run for a week.

I've tried 'xrestop', too; stopped the compiz window effects (that slowed down the resource leak), but still cannot find out why this is happening. It's almost like being back on a WinXP machine... :-(

So yes! Better X debugging tools would be good. One problem with 'xrestop' is that it requires resources, too, so once you hit the wall, even it won't run.

As a tip to others who get stuck by this (eg: when resuming from Standby and waiting for the password window that will never appear because there are no resources to create it), switching to a frame buffer terminal and back (Ctrl-Alt-F1, then Ctrl-Alt-F7) seems to free a few of the critical resources.

Doug

share|improve this answer
    
Just did some more searching and found a useful Python script to debug my problem (thanks Adam!). This allowed me to notice that an addon to my mail program, Thunderbird's Minimize-to-tray, was consuming extra file descriptors, 4 per minimize. Disabling it appears to have resolved the problem. –  user10906 Feb 15 '11 at 21:42
    
@user10906 That script is unusable: IndexError: list index out of range because some lines hasn't Path in netstat -an --unix output. –  Simón Jan 7 '13 at 11:52
    
@Simón I've fixed that script, see gist.github.com/vorburger/8369050. Although I'm not sure what to do with it, yet... ;-) –  vorburger Jan 11 at 10:03
add comment

I managed to resolve this "deadlock", where none of the x-tools worked since they too need to connect to the X server, by using lsof -U which lists the processes that are using socket files.

In this example it was a bad startup script that spawned new "badproc" processes out of bounds.

Example output from lsof -U:

COMMAND    PID      USER   FD   TYPE     DEVICE SIZE   NODE NAME
badproc   4770 bohrax       3u  unix 0xf3ba9540       13011 socket
xfce4-ses 4773 bohrax       3u  unix 0xf3bd21c0       13024 socket
xfce4-ses 4773 bohrax       4u  unix 0xf39ef000       13080 /tmp/.ICE-unix/4773
xfce4-ses 4773 bohrax      13u  unix 0xf3bf81c0       13563 socket
xfce4-ses 4773 bohrax      14u  unix 0xf3bf8a80       13565 /tmp/orbit-bohrax   /linc-12a5-0-78fe5c0776a06
xfce4-ses 4773 bohrax      15u  unix 0xf3bf8e00       13568 /tmp/orbit-bohrax   /linc-12a5-0-78fe5c0776a06
xfce4-ses 4773 bohrax      16u  unix 0xf3b411c0       13580 /tmp/.ICE-unix/4773
xfce4-ses 4773 bohrax      17u  unix 0xf0074380       13688 /tmp/.ICE-unix/4773
xfce4-ses 4773 bohrax      18u  unix 0xf3b6e380       13621 /tmp/.ICE-unix/4773
xfce4-ses 4773 bohrax      21u  unix 0xf0074c40       13778 /tmp/.ICE-unix/4773
badproc   4775 bohrax       1u  unix 0xf3bd2540       13013 socket
badproc   4781 bohrax       1u  unix 0xf3bd2c40       13021 socket
xfce-mcs- 4821 bohrax       3u  unix 0xf3be5540       13456 socket
xfce-mcs- 4821 bohrax       5u  unix 0xf3ba98c0       13484 socket
xfwm4     4827 bohrax       3u  unix 0xf3be5a80       13573 socket
xfwm4     4827 bohrax       4u  unix 0xf3b41000       13579 socket
Thunar    4831 bohrax       3u  unix 0xf3b6b000       13598 socket
Thunar    4831 bohrax       8u  unix 0xf3b6be00       13613 socket
Thunar    4831 bohrax       9u  unix 0xf3b41e00       13617 socket
Thunar    4831 bohrax      10u  unix 0xf3b6e1c0       13620 socket
Thunar    4831 bohrax      13u  unix 0xf0022000       13643 socket
gam_serve 4834 bohrax       4u  unix 0xf3b6b540       13607 socket
gam_serve 4834 bohrax       7u  unix 0xf3b41c40       13614 socket
gam_serve 4834 bohrax       8u  unix 0xf0020000       13656 socket
xfdesktop 4836 bohrax       3u  unix 0xf3b6ee00       13652 socket
xfdesktop 4836 bohrax       8u  unix 0xf3be5000       13655 socket
xfdesktop 4836 bohrax       9u  unix 0xf0020540       13665 socket
xfdesktop 4836 bohrax      10u  unix 0xf0020380       13667 socket
xfdesktop 4836 bohrax      13u  unix 0xf0074000       13687 socket
python    4837 bohrax       4u  unix 0xf00208c0       13672 socket
python    4837 bohrax       8u  unix 0xf3b6bc40       13880 socket
dbus-laun 4841 bohrax       3u  unix 0xf3b6ec40       13627 socket
dbus-laun 4841 bohrax       6u  unix 0xf0022c40       13644 socket
dbus-laun 4841 bohrax       8u  unix 0xf3b6be00       13613 socket
dbus-daem 4842 bohrax       3u  unix 0xf00221c0       13640 socket
dbus-daem 4842 bohrax       8u  unix 0xf3b6be00       13613 socket
dbus-daem 4842 bohrax       9u  unix 0xf00228c0       13641 socket
dbus-daem 4842 bohrax      10u  unix 0xf0022a80       13642 socket
dbus-daem 4842 bohrax      13u  unix 0xf0022380       13646 socket
dbus-daem 4842 bohrax      14u  unix 0xf00201c0       13666 socket
dbus-daem 4842 bohrax      15u  unix 0xf3b41540       13796 socket
dbus-daem 4842 bohrax      16u  unix 0xf3bd28c0       13881 socket
badproc   6314 bohrax       3u  unix 0xde00d380       95944 socket
badproc   6315 bohrax       1u  unix 0xde00d540       95946 socket
badproc   6322 bohrax       3u  unix 0xde00d8c0       96515 socket
badproc   6323 bohrax       1u  unix 0xde00de00       96517 socket
badproc   6330 bohrax       3u  unix 0xdf7ea000       97181 socket
badproc   6331 bohrax       1u  unix 0xdf7ea540       97184 socket
badproc   6338 bohrax       3u  unix 0xdf7ea8c0       97736 socket
badproc   6339 bohrax       1u  unix 0xde0481c0       97737 socket
badproc   6345 bohrax       3u  unix 0xde048700       98209 socket
badproc   6346 bohrax       1u  unix 0xde0488c0       98210 socket
badproc   6352 bohrax       3u  unix 0xde048e00       98776 socket
badproc   6353 bohrax       1u  unix 0xde058000       98778 socket
badproc   6359 bohrax       3u  unix 0xde058700       99293 socket
badproc   6360 bohrax       1u  unix 0xde0588c0       99296 socket
badproc   6367 bohrax       3u  unix 0xde08c000       99841 socket
badproc   6368 bohrax       1u  unix 0xde08c540       99842 socket
badproc   6375 bohrax       3u  unix 0xde08c8c0      100365 socket
badproc   6376 bohrax       1u  unix 0xde058c40      100367 socket
badproc   6383 bohrax       3u  unix 0xde09d1c0      101008 socket
badproc   6384 bohrax       1u  unix 0xde09d540      101010 socket
badproc   6392 bohrax       3u  unix 0xde09dc40      101681 socket
badproc   6393 bohrax       1u  unix 0xdf70a1c0      101682 socket
badproc   6400 bohrax       3u  unix 0xdf70a380      102324 socket
badproc   6401 bohrax       1u  unix 0xdf70a700      102325 socket
badproc   6409 bohrax       3u  unix 0xdf70ae00      102982 socket
badproc   6410 bohrax       1u  unix 0xde0ce1c0      102984 socket
badproc   6417 bohrax       3u  unix 0xde0ce380      103556 socket
badproc   6418 bohrax       1u  unix 0xde0ce8c0      103561 socket
badproc   6424 bohrax       3u  unix 0xde0cee00      104133 socket
badproc   6425 bohrax       1u  unix 0xde0bd000      104135 socket
badproc   6432 bohrax       3u  unix 0xde0bd380      104716 socket
badproc   6433 bohrax       1u  unix 0xde0bd8c0      104717 socket
badproc   6440 bohrax       3u  unix 0xde120000      105280 socket
badproc   6441 bohrax       1u  unix 0xde120540      105285 socket
badproc   6448 bohrax       3u  unix 0xde1208c0      105907 socket
badproc   6449 bohrax       1u  unix 0xde0bdc40      105908 socket
badproc   6456 bohrax       3u  unix 0xf01701c0      106486 socket
badproc   6457 bohrax       1u  unix 0xf0170540      106488 socket
badproc   6465 bohrax       3u  unix 0xf0170c40      107123 socket
badproc   6466 bohrax       1u  unix 0xf0170e00      107126 socket
badproc   6473 bohrax       3u  unix 0xde140000      107774 socket
badproc   6474 bohrax       1u  unix 0xde140540      107778 socket
badproc   6479 bohrax       3u  unix 0xde1408c0      108239 socket
badproc   6480 bohrax       1u  unix 0xde1881c0      108240 socket
badproc   6488 bohrax       3u  unix 0xde188700      108825 socket
badproc   6489 bohrax       1u  unix 0xde1888c0      108828 socket
badproc   6495 bohrax       3u  unix 0xde188e00      109377 socket
badproc   6496 bohrax       1u  unix 0xde18f000      109379 socket
badproc   6503 bohrax       3u  unix 0xde18f380      109907 socket
badproc   6504 bohrax       1u  unix 0xde18f8c0      109909 socket
badproc   6511 bohrax       3u  unix 0xde1c8000      110488 socket
badproc   6512 bohrax       1u  unix 0xde1c8540      110489 socket
badproc   6519 bohrax       3u  unix 0xde1c88c0      111070 socket
badproc   6520 bohrax       1u  unix 0xde18fc40      111071 socket
badproc   6527 bohrax       3u  unix 0xde1fa1c0      111629 socket
badproc   6528 bohrax       1u  unix 0xde1fa540      111631 socket
badproc   6531 bohrax       3u  unix 0xde1fa8c0      111899 socket
badproc   6532 bohrax       1u  unix 0xde1fae00      111901 socket
badproc   6535 bohrax       3u  unix 0xde219000      111998 socket
badproc   6536 bohrax       1u  unix 0xde219540      112000 socket
badproc   6539 bohrax       3u  unix 0xde2198c0      112114 socket
badproc   6540 bohrax       1u  unix 0xde2431c0      112116 socket
badproc   6547 bohrax       3u  unix 0xde243380      112663 socket
badproc   6548 bohrax       1u  unix 0xde2438c0      112664 socket
badproc   6555 bohrax       3u  unix 0xde243c40      113256 socket
badproc   6556 bohrax       1u  unix 0xde251000      113258 socket
badproc   6564 bohrax       3u  unix 0xde251700      113931 socket
badproc   6565 bohrax       1u  unix 0xde2518c0      113932 socket
badproc   6572 bohrax       3u  unix 0xde291000      114525 socket
badproc   6573 bohrax       1u  unix 0xde291540      114526 socket
badproc   6579 bohrax       3u  unix 0xde291c40      115112 socket
badproc   6580 bohrax       1u  unix 0xde251c40      115113 socket
badproc   6588 bohrax       3u  unix 0xde274380      115733 socket
badproc   6589 bohrax       1u  unix 0xde274540      115738 socket
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.