1

I am having an issue that I think is associated with X, xrandr and maybe WM I am using. I am on

  • Debian 8 stable, updated;
  • Intel graphics,
  • i3wm, no DE
  • lightDM (not sure if this is relevant, but at some point I thought it might be). I used GDM at the time of the crash, then tried to install lightdm. I don't know the intricacies of authentication of X by the DM.

Here is the scenario. I come home and connect my laptop to two monitors (VGA1 and HDMI1) and turn off LVDS1. For that I have a function in .bashrc

function duo {
    xrandr --output HDMI1 --right-of LVDS1
    xrandr --output LVDS1 --off # this is probably bad, but it still works thanks to xrandr
    xrandr --output HDMI1 --mode 1280x1024
    xrandr --output HDMI1 --right-of VGA1
    xrandr --output HDMI1 --rotate left
    xrandr --output VGA1 --mode 1280x1024
}

The function is messy because I was experimenting and trying to break down how xrandr should change layout. This works 100% of the time without issues. When I want to disconnect and go back to "laptop" mode I pull out both cables and press Super+Shift+F8 which in my i3wm is bound to xrandr --auto, which should disconnect VGA1 and HDMI1 since they are not plugged in anymore and i3wm will move all workspaces to single screen. Sometimes this works, but almost often X server crashes and drops into DM prompting for login. So I lose all of applications open and possibly files (although I am OCD when it comes to saving).

Here is a syslog. It starts with a line printed by my script that's bound to Super+Shift+F8 in my i3wm config file. The reason for this shortcut is that I don't have a udev rule for VGA or HDMI. I had a rule that ran a script, but removed it. I can post, but the post is already very big - don't want to clutter it. So when I unplug HDMI or VGA my LVDS goes black and this script should turn it on. I can also post Xorg.log, from /var/log, but it does not seem to have anything useful (I will post, but again - they are long - please let me know).

Now a complication: I have Gnome 3 installed that came with Debian 8 install. When I use it and no i3wm - everything works and X does not crash! So I can plug-in 2 monitors, turn off LVDS and unplug hot and safely. It's not that I don't like Gnome, but I am very used to i3wm and minimal light set up (use the same on my Arch desktop). Laptop is also old for Gnome3. I'd rather not go into trying other DE's.

#!/bin/bash
# Super+Shift+F8 is bound to this script in WM
function laptop() {
  xrandr --auto
  xrandr --output VGA1 --off
  xrandr --output HDMI1 --off
}
echo "running laptop script"
laptop


Oct 21 20:13:12 debianone /etc/gdm3/Xsession[8574]: running laptop script
Oct 21 20:13:12 debianone /etc/gdm3/Xsession[8574]: xrandr: cannot find crtc for output LVDS1
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) intel(0): Allocated new frame buffer 1024x1280 stride 4096, tiled
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: X Error of failed request:  BadMatch (invalid parameter attributes)
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Major opcode of failed request:  140 (RANDR)
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Minor opcode of failed request:  21 (RRSetCrtcConfig)
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Serial number of failed request:  35
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Current serial number in output stream:  35
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: i3: No usable outputs available.
Oct 21 20:13:13 debianone org.gtk.vfs.Daemon[8621]: A connection to the bus can't be made
Oct 21 20:13:13 debianone org.gtk.vfs.Daemon[8621]: g_dbus_connection_real_closed: Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting.
Oct 21 20:13:13 debianone org.a11y.Bus[8621]: g_dbus_connection_real_closed: Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting.
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: [9400:9400:1021/201313:ERROR:chrome_browser_main_extra_parts_x11.cc(57)] X IO error received (X server probably went away)
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: [libi3] libi3/font.c Using Pango font DejaVu Sans Mono, size 8
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: [libi3] libi3/font.c X11 root window dictates 98.223565 DPI
Oct 21 20:13:13 debianone org.a11y.atspi.Registry[8648]: XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
Oct 21 20:13:13 debianone org.a11y.atspi.Registry[8648]: after 1608 requests (1608 known processed) with 0 events remaining.
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: drracket: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: [9434:9434:1021/201313:ERROR:x11_util.cc(82)] X IO error received (X server probably went away)
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Can't open display :0
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Exiting due to signal.
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: after 2716 requests (2716 known processed) with 0 events remaining.
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[4989]: Process 8664 dead!
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[4989]: Warning: no target process found. Waiting for it...
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Process 8664 dead!
Oct 21 20:13:13 debianone /etc/gdm3/Xsession[8574]: Warning: no target process found. Waiting for it...
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "synaptics"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: AT Translated Set 2 keyboard: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Asus WMI hotkeys: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: USB Camera: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Microsoft Microsoft® Nano Transceiver v1.0: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Microsoft Microsoft® Nano Transceiver v1.0: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Microsoft Microsoft® Nano Transceiver v1.0: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Logitech USB Keyboard: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Logitech USB Keyboard: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Sleep Button: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Video Bus: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) evdev: Power Button: Close
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (II) UnloadModule: "evdev"
Oct 21 20:13:13 debianone gdm-Xorg-:0[8485]: (EE) Server terminated successfully (0). Closing log file.

I've seen bugreports on similar issues in X, KDE, Debian and Ubuntu and they show fixed. I am definitely updated to latest and still crashing. Do I need to backport newer X? Or something else?

  • It's worth adding that I asked this on Debian forum and did not get a reply for a month. So I resorted to SE. – Serge Poele Oct 22 '15 at 18:38
3

It's likely that the rapid succession of xrandr messages is triggering a bug in the X server. I would suggest you do two things:

  • File a bug against the X server. It is not supposed to crash, no matter what you do (at worst, it should produce an error message)
  • Change your script so that it calls xrandronly once:

    xrandr --output LVDS --off --output VGA1 --mode 1280x1024 --output HDMI1 --mode 1280x1024 --rotate left --right-of VGA1
    

    The point here is that you can pass multiple commands per output to xrandr, as well as multiple outputs. I would personally also set one of the outputs as the primary output (with --primary), but that's not critical.

EDIT: Looking at the log in a bit more detail, we see this:

Oct 21 20:13:12 debianone /etc/gdm3/Xsession[8574]: xrandr: cannot find crtc for output LVDS1

A CRTC is a display controller chip; the actual component which transforms the frame buffer generated by the GPU into scanlines which are then sent out over whatever output is selected (VGA, DVI, HDMI, DisplayPort, yada yada); the abbreviation stands for Cathode Ray Tube Controller, although that terminology is obviously somewhat outdated. Most GPUs have less of those than they have outputs, and the number of CRTCs is usually the limiting factor that decides how many monitors a GPU card can steer at the same time. Up to a few years ago, for most of Intel's mobile GPUs that number was two, although with the appearance of 4K screens (which require two CRTCs per monitor) most modern mobile GPUs now have three.

Since the system also talks about LVDS (which is an older standard now being replaced by embedded display port or eDP), it's a pretty safe bet to assume you have two CRTCs.

What the error message that I quoted above means is that when you ask the X server to enable the LVDS panel, it looks for an available CRTC and doesn't find one. Things then seem to go horribly wrong. The solution to your problem would therefore be to ensure there is an available CRTC when you try to enable the external monitor, by disabling the external outputs before you enable the internal ones rather than afterwards, as you're trying to do now.

  • Thanks @Wouter. Rapid succession was a concern for me too. I remember reading about a race condition on some buffers in X, but don't look into the details. I added sleep 1 after each one of them, which did not help, but I also can't say with full confidence that sleep 1 should slowing down the succession. Once I have more time I will file a bug with X, but will be using Gnome3 meanwhile. Thanks for the reply. That's the first one I got in a long time. – Serge Poele Oct 23 '15 at 19:01
  • Did you try doing all your settings in just one xrandr call, like I showed you? Did it help? – Wouter Verhelst Oct 23 '15 at 20:14
  • I did, but it never crashed before on setting the dual screen setup. It crashed to exiting to: unplugging both VGA and HDMI and turning LVDS back on. Then it crashes (almost always). It does not crash as often on 2 displays. (This is a bit of an aside, but I also had the same issue on Mint 17 when I ran i3wm on it as opposed to running a DE. When I remembered that it kind of got me thinking if i3 is doing something, but I haven't debugged.) – Serge Poele Oct 23 '15 at 20:49
  • Ah! That wasn't clear from your question, sorry. – Wouter Verhelst Oct 23 '15 at 20:51
  • thank you for the explanation. It makes sense that if there is no crtc available it will cause problems. I tried this command and experienced a crash (dropped into DM) as soon as I hit enter: xrandr --output VGA1 --off --output HDMI1 --off. If I run this xrandr --output VGA1 --off --output HDMI1 --off --output LVDS1 --auto I get "cannot find crtc for output LVDS1". I am a little confused: I expected xrandr to "parse" first two instruction to turn external displays off first freeing crtc for LVDS1. Probably time to look into how xrandr works... – Serge Poele Oct 24 '15 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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