Bug 62341

Summary: Xorg segfaults when starting with no monitor connected
Product: xorg Reporter: Andreas Lampersperger <lampersperger.andreas>
Component: Server/GeneralAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: lampersperger.andreas, pasik
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Same patch as in Description none

Description Andreas Lampersperger 2013-03-14 13:58:58 UTC
Created attachment 76529 [details]
Same patch as in Description

When starting Xorg on a machine without monitor attached, Xorg segfaults when starting e.g. xrandr.

I already did some debugging and created the following patch, which fixes this problem:

Index: xorg-server-1.13.3/hw/xfree86/modes/xf86Crtc.h
===================================================================
--- xorg-server-1.13.3.orig/hw/xfree86/modes/xf86Crtc.h
+++ xorg-server-1.13.3/hw/xfree86/modes/xf86Crtc.h
@@ -730,7 +730,7 @@ static _X_INLINE xf86OutputPtr
 xf86CompatOutput(ScrnInfoPtr pScrn)
 {
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-
+    if ( config->compat_output == -1 ) return NULL;
     return config->output[config->compat_output];
 }

Please add this fix to git.

Andreas
Comment 1 Adam Jackson 2018-06-13 18:06:00 UTC
commit 28159eff6badf6181b255f26d1f444abe81c05b7
Author: Jason Gerecke <killertofu@gmail.com>
Date:   Thu Apr 30 18:06:14 2015 -0700

    xfree86: Return NULL from xf86CompatOutput if no compat_output is defined
    
    If no compat_output is defined, we inadvertently (attempt to) return
    whatever data is at index -1. Instead, return NULL since that's what
    callers are expecting.
    
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>

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.