Bug 86665 - Xorg does not close old /dev/dri/card0 connections
Summary: Xorg does not close old /dev/dri/card0 connections
Status: RESOLVED MOVED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/Ext/DRI (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2014-11-24 15:34 UTC by Isabelle
Modified: 2018-12-13 18:32 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Xorg log file (70.78 KB, text/plain)
2016-03-14 11:53 UTC, Tyna Pelletier
no flags Details
outpout of lsof command (13.38 KB, text/plain)
2016-03-14 11:55 UTC, Tyna Pelletier
no flags Details

Description Isabelle 2014-11-24 15:34:09 UTC
Recently I've been getting a lot of "maximum number of x clients reached" errors. On my computer I run two X servers. I switch between them pretty regularly with crtl+alt+f1/f2.

I've been trying to figure out why I keep getting this error. xlsclients only lists 12 items, xrestop doesn't show much more. As of this writing I'm currently getting this error and cannot open any more processes. `lsof -U` lists 203 items (mostly chromium, but I don't think that's the problem here), but `sudo ls /proc/2541/fd` has 259 items (2541 is the pid of Xorg.bin.)

Now here's the thing, if I switch between my two x servers with ctrl+alt+f1/f2 (this works even if tty2 is a framebuffer) the number of items in /proc/2541/fd increases by one. Indeed if I run `sudo ls -p 2541` there's a new entry, /dev/dri/card0

I think that every time I switch, X re-opens my graphics card, but never closes the old connection. the number of items lsof -U doesn't change when I do this, so none of my programs are to blame, this is just X.

Because there are a lot of old connections floating around, I'm guessing the number of clients X can have is severely limited. I think this is why I'm getting these errors.

Not sure if this is a DRI extension error, saw the dri in /dev/dri/card0 and assumed.

I just updated three days ago too. Still have this problem.

~$ Xorg.bin -version
X.Org X Server 1.16.2
Release Date: 2014-11-10
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.17.2-1-ARCH x86_64 
Current Operating System: Linux blackle-thinkpad 3.17.3-3-ck #1 SMP PREEMPT Tue Nov 18 16:50:56 EST 2014 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux-ck root=UUID=65d91862-d03e-4b93-b52c-6dae55b39a97 ro nox2apic rcutree.rcu_idle_gp_delay=1 init=/usr/lib/systemd/systemd
Build Date: 10 November 2014  07:52:13PM
 
Current version of pixman: 0.32.6
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Comment 1 Tyna Pelletier 2016-03-11 12:28:41 UTC
Hi,
I can confirm that issue is still present in 2016:
I'm running archlinux with the latest xorg.

Steps to reproduce:
1. Start X server (via a display manager or xinitrc it doesn't matter).
2. Login to another tty.
3. Switch between them and use 'lsof -p ($pidof Xorg) | wc -l to monitor.

Each time, the number will increase, till it reaches the limit and even above (I got 702 last time), and start throwing 'maximum number of clients reached' errors.
Comment 2 Michel Dänzer 2016-03-14 08:39:47 UTC
Please attach the Xorg log file corresponding to the problem.
Comment 3 Tyna Pelletier 2016-03-14 11:53:54 UTC
Created attachment 122274 [details]
Xorg log file
Comment 4 Tyna Pelletier 2016-03-14 11:55:53 UTC
Created attachment 122275 [details]
outpout of lsof command
Comment 5 Tyna Pelletier 2016-03-14 11:56:57 UTC
Hi,
here's the output of 'lsof -p $(pidof Xorg)' and my xorg0.log files. I hope this will be useful :)

If you want other files, just tell me and I'll attach them too.

Thanks
Comment 6 Chris Wilson 2016-03-14 12:19:24 UTC
diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c
index 13784d1..9f196ef 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -417,9 +417,10 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
         /* info->vt_active gets set by systemd_logind_vtenter() */
         info->active = TRUE;
 
-        if (pdev)
+        if (pdev) {
+            close(fd);
             pdev->flags &= ~XF86_PDEV_PAUSED;
-        else
+        } else
             systemd_logind_set_input_fd_for_all_devs(major, minor, fd,
                                                      info->vt_active);
Comment 7 Adam Jackson 2018-06-13 19:02:43 UTC
Calling comment #6 a "patch" is a bit generous, but.
Comment 8 GitLab Migration User 2018-12-13 18:32:09 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/204.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.