Xorg guest session fails to start if the user has logged out and logged in again

Bug #1256150 reported by Alistair Buxton
42
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Light Display Manager
Fix Released
High
Unassigned
1.8
Fix Released
High
Unassigned
lightdm (Ubuntu)
Fix Released
High
Robert Ancell
Saucy
Won't Fix
High
Robert Ancell
Trusty
Fix Released
High
Robert Ancell

Bug Description

[Impact]
Unable to switch sessions.

[Test Case]
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.)

[Regression Potential]
Low. Bug is a simple fix for wrong logic and has been running in Ubuntu 14.04 for some time without issue.

Related branches

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :
description: updated
Revision history for this message
Alistair Buxton (a-j-buxton) wrote :
description: updated
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in lightdm (Ubuntu):
status: New → Confirmed
Changed in xorg (Ubuntu):
status: New → Confirmed
Changed in lightdm (Ubuntu):
importance: Undecided → High
Changed in xorg (Ubuntu):
importance: Undecided → High
Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

If you search for "VT" in the Xorg.1.log you can see it attempts to start Xorg on VT 7... which is the VT where :0 is running. When everything works correctly, :1 should be started on VT 8, and the log confirms it.

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

This is visible on the lightdm log too. Here it is, trying to start :1 on VT7, which is already in use by :0

[+101.59s] DEBUG: Seat: Starting local X display
[+101.59s] DEBUG: Using VT 7
[+101.59s] DEBUG: DisplayServer x-1: Logging to /var/log/lightdm/x-1.log
[+101.59s] DEBUG: DisplayServer x-1: Writing X server authority to /var/run/lightdm/root/:1
[+101.59s] DEBUG: DisplayServer x-1: Launching X Server
[+101.59s] DEBUG: Launching process 2773: /usr/bin/X -core :1 -auth /var/run/lightdm/root/:1 -nolisten tcp vt7 -novtswitch
[+101.59s] DEBUG: DisplayServer x-1: Waiting for ready signal from X server :1
[+107.81s] DEBUG: Process 2773 terminated with signal 6
[+107.81s] DEBUG: DisplayServer x-1: X server stopped
[+107.81s] DEBUG: Releasing VT 7
[+107.81s] DEBUG: DisplayServer x-1: Removing X server authority /var/run/lightdm/root/:1

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

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.

Revision history for this message
Thaddaeus Tintenfisch (thad-fisch-deactivatedaccount) wrote :

The fix from the linked branch does work for me, no more screen corruption after relogging once and then locking the screen via lightdm (light-locker).

Changed in xorg (Ubuntu):
status: Confirmed → Invalid
no longer affects: xorg (Ubuntu)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:lightdm at revision None, scheduled for release in lightdm, milestone Unknown

Changed in lightdm:
status: New → Fix Committed
Changed in lightdm (Ubuntu Saucy):
status: New → In Progress
Changed in lightdm (Ubuntu Trusty):
status: Confirmed → In Progress
assignee: nobody → Robert Ancell (robert-ancell)
Changed in lightdm (Ubuntu Saucy):
importance: Undecided → High
assignee: nobody → Robert Ancell (robert-ancell)
Changed in lightdm:
importance: Undecided → High
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lightdm - 1.9.4-0ubuntu1

---------------
lightdm (1.9.4-0ubuntu1) trusty; urgency=low

  * New upstream release:
    - Fix issue where VTs are double used when switching sessions.
      (LP: #1256150)
    - Remove lightdm-set-defaults and gdmflexiserver.
    - Add new ability to specify a list of seat types to try, rather than just
      one.
    - Allow Mir sessions in the surfaceflinger seat.
    - Rename the guest session wrapper to have a simpler name.
    - Make sure sessions are associated with the display server before starting
      them.
    - Add a dm-tool man page.
 -- Robert Ancell <email address hidden> Tue, 03 Dec 2013 19:07:28 +1300

Changed in lightdm (Ubuntu Trusty):
status: In Progress → Fix Released
Changed in lightdm:
milestone: none → 1.9.4
status: Fix Committed → Fix Released
description: updated
Revision history for this message
Chris Halse Rogers (raof) wrote : Please test proposed package

Hello Alistair, or anyone else affected,

Accepted lightdm into saucy-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/lightdm/1.8.6-0ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in lightdm (Ubuntu Saucy):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Sean (scott-seanc) wrote :

Possible duplicate of 1248948.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

saucy has seen the end of its life and is no longer receiving any updates. Marking the saucy task for this ticket as "Won't Fix".

Changed in lightdm (Ubuntu Saucy):
status: Fix Committed → Won't Fix
To post a comment you must log in.
This report contains Public information  
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.