Bug 19643

Summary: X server crash after undocking laptop with LVDS off
Product: xorg Reporter: Frans Pop <elendil>
Component: Server/DDX/XorgAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: bryce, theholyettlz
Version: 7.3 (2007.09)   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Full Xorg log
none
check_null_modes.patch
none
157_check_null_modes.patch none

Description Frans Pop 2009-01-18 10:19:36 UTC
Created attachment 22086 [details]
Full Xorg log

I have a HP 2510p notebook with docking station running Debian Lenny, kernel is self-compiled 2.6.28.

When I log in to KDE, a script is started automatically that "listens" for dock/undock events and automatically calls xrandr to enable/disable dual-display (Xinerama).

I get an Xserver crash if I start a VirtualBox 2.1.0 virtual machine after undocking the notebook while the LVDS is off. After the crash Xorg.0.log.old contains:
<snip>
Backtrace:
0: /usr/bin/X(xf86SigHandler+0x6a) [0x48dd0a]
1: /lib/libc.so.6 [0x7fe702829f60]
2: /usr/bin/X(VidModeGetFirstModeline+0x5b) [0x49053b]
3: /usr/bin/X(VidModeGetNumOfModes+0x42) [0x490772]
4: /usr/lib/xorg/modules/extensions//libextmod.so [0x7fe701c60040]
5: /usr/bin/X(Dispatch+0x342) [0x44f7e2]
6: /usr/bin/X(main+0x4a5) [0x436bd5]
7: /lib/libc.so.6(__libc_start_main+0xe6) [0x7fe7028161a6]
8: /usr/bin/X(FontFileCompleteXLFD+0x281) [0x435e99]

Fatal server error:
Caught signal 11.  Server aborting
</snip>

After the crash I see display corruption of VT1 (after switching consoles or during shutdown).
I am using the VESA framebuffer on VT1 (vga=791). The corruption is that after a console switch most of the display is either black or shows part of the KDE desktop; at the bottom there is an area of grey horizontal stripes, and at the top there is a small bar where the text of the console looks to be displayed, but in an extremely small font (unreadable, but you can just recognize console messages "scrolling" in that area).
Switching back from VT1 to X.Org works correctly, and if I log in to X.Org  again and retry VirtualBox it works correctly. A reboot is needed to get VT1 displayed correctly again.

The issue can be reproduced both with PAT and without PAT enabled for the kernel and also happens with kernel version 2.6.26.3. I've seen it happen with both with VirtualBox 2.0.1 and 2.1.0.

The crash can be reproduced as follows:
- boot with notebook docked
- log in to KDE and activate dual display with:
  xrandr --output VGA --left-of LVDS --mode 1280x1024
- disable the laptop display:
  xrandr --output LVDS --off
- undock the notebook, which results in:
  xrandr --output LVDS --auto --output VGA --off
- start VirtualBox virtual machine

The crash does not happen if I redock the notebook before starting VirtualBox. The display corruption on VT1 only happens after an X.Org crash.

I can also reproduce it if I disable the dock/undock script and instead run these xrandr commands manually.

Interesting is that the crash does not happen if I split the last xrandr command and first activate the LVDS and only then disable the VGA.
So if instead of:
xrandr --output LVDS --auto --output VGA --off
I do:
xrandr --output LVDS --auto
xrandr --output VGA --off
Comment 1 Frans Pop 2009-01-26 21:25:07 UTC
Additional info

1) I also see the crash with other programs than VirtualBox. Example is the
   game "einstein".
2) The workaround I mentioned (to first enable LVDS) does not prevent
   the crash after all.
Comment 2 Julien Cristau 2009-02-04 06:17:25 UTC
*** Bug 19948 has been marked as a duplicate of this bug. ***
Comment 3 Bryce Harrington 2009-02-04 06:26:36 UTC
Created attachment 22576 [details] [review]
check_null_modes.patch
Comment 4 Frans Pop 2009-02-04 08:33:10 UTC
The proposed patch fails to compile for me with Debian's xserver-xorg package (1.4.2) as the pVidMode struct does not have a modes variable.

I tried the following instead and with that I no longer got the crash in a quick first test:
     pScrn = xf86Screens[scrnIndex];
     pVidMode = VMPTR(pScrn->pScreen);
+    if (pScrn->modes == NULL)
+        return FALSE;
+
     pVidMode->First = pScrn->modes;
     pVidMode->Next =  pVidMode->First->next;

On IRC Julien Cristau confirmed that this should be correct.
Comment 5 Bryce Harrington 2009-02-04 21:33:11 UTC
Created attachment 22595 [details] [review]
157_check_null_modes.patch

Fixed

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.