I now know exactly what causes this bug. The problem is that the VT gets unref'd once when the server shuts down, and then unref'd again much later when the object gets finalized. This might happen after the VT has already been allocated and ref'd to another server. This makes lightdm think the VT is free, when it isn't.
This is an annotated log, with extra debugging code added: *** I've logged in (once) and now I log out for the first time. [+34.12s] DEBUG: Session pid=13236: Exited with return value 0 [+34.12s] DEBUG: Seat: Session stopped [+34.12s] DEBUG: Seat: Stopping display server, no sessions require it [+34.12s] DEBUG: Sending signal 15 to process 13176 [+34.47s] DEBUG: Process 13176 exited with return value 0 [+34.47s] DEBUG: DisplayServer x-0: X server stopped :0, pid was 0 [+34.47s] DEBUG: Releasing VT 7 *** The display server shuts down and the VT is unref'd. [+34.47s] DEBUG: DisplayServer x-0: Removing X server authority /var/run/lightdm/root/:0 [+34.47s] DEBUG: Seat: Display server stopped [+34.47s] DEBUG: Seat: Active display server stopped, starting greeter [+34.47s] DEBUG: Seat: Creating greeter session [+34.47s] DEBUG: Seat: Setting XDG_SEAT=seat0 [+34.47s] DEBUG: Seat: Creating display server of type x [+34.47s] DEBUG: Seat: Starting local X display *** New server starts for the login screen [+34.47s] DEBUG: DisplayServer x-0: Set VT of server:0 to 7 *** It uses VT7 because it's unref'd [+34.47s] DEBUG: Using VT 7 *** This causes VT7 to get ref'd. [+34.47s] DEBUG: DisplayServer x-0: Logging to /var/log/lightdm/x-0.log [+34.47s] DEBUG: DisplayServer x-0: Writing X server authority to /var/run/lightdm/root/:0 [+34.47s] DEBUG: DisplayServer x-0: Launching X Server [+34.47s] DEBUG: Launching process 13592: /usr/bin/X -core :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch [+34.47s] DEBUG: DisplayServer x-0: Waiting for ready signal from X server :0, pid=13592 *** New server launches. [+34.47s] DEBUG: DisplayServer x-0: In finalize (null): vt=7 [+34.48s] DEBUG: Releasing VT 7 *** The old x-server-local object gets finalized, which causes VT7 to get unref'd for a second time. The next server that starts up will start on VT7, which is really currently already used. -- You received this bug notification because you are a member of Desktop Packages, which is subscribed to lightdm in Ubuntu. https://bugs.launchpad.net/bugs/1256150 Title: Xorg guest session fails to start if the user has logged out and logged in again Status in “lightdm” package in Ubuntu: Confirmed Status in “xorg” package in Ubuntu: Confirmed Bug description: Steps to reproduce: 1. Log in to the desktop. 2. Log out again. (But don't reboot or anything like that.) 3. Log in again. 4. Start a guest session. Result: Depends on Xorg server in use. With intel driver, the guest Xorg session fails to start up with a DRM permission error (see attached Xorg.1.log). With virtualbox, and possibly AMD proprietary driver, the Xorg session on :1 appears to fight the one on :0 for control of the framebuffer - windows from both desktops get drawn over each other, causing a big mess. The login/logout step is important: if you log in to the desktop immediately after the lightdm session has been started or restarted ("sudo service lightdm restart"), then the :1 session will start correctly. (This problem can also be reproduced in another way: some desktops, when locking the display, create a new greeter instance on :1. This will also fail if the user has logged out and logged in again. For example, Xubuntu does this.) ProblemType: Bug DistroRelease: Ubuntu 14.04 Package: lightdm 1.9.3-0ubuntu1 ProcVersionSignature: Ubuntu 3.12.0-4.12-generic 3.12.1 Uname: Linux 3.12.0-4-generic x86_64 ApportVersion: 2.12.7-0ubuntu1 Architecture: amd64 CurrentDesktop: Unity Date: Fri Nov 29 01:41:28 2013 InstallationDate: Installed on 2013-11-29 (0 days ago) InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Alpha amd64 (20131128) SourcePackage: lightdm UpgradeStatus: No upgrade log present (probably fresh install) To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1256150/+subscriptions -- Mailing list: https://launchpad.net/~desktop-packages Post to : [email protected] Unsubscribe : https://launchpad.net/~desktop-packages More help : https://help.launchpad.net/ListHelp

