Bug 16301

Summary: Missing Screen line in ServerLayout crashes the server
Product: xorg Reporter: Georgi Mirchev <gmirchev>
Component: Server/GeneralAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: minor    
Priority: medium    
Version: 6.8.99.902 (6.9 RC2)   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Example xorg.conf to produce the error
none
0001-xfree86-return-an-error-if-Screen-is-missing-from-S.patch
none
0001-xfree86-handle-missing-Screen-lines-in-the-ServerLa.patch none

Description Georgi Mirchev 2008-06-10 18:01:54 UTC
Created attachment 17042 [details]
Example xorg.conf to produce the error

If in the "ServerLayout" section there is no Screen option the server crashes upon start.

The segfault happens in xf86Init.c at this line:
   GDevPtr configured_device = xf86ConfigLayout.screens->screen->device;

Expected behavior is to produce an descriptive error message.
Comment 1 Peter Hutterer 2008-06-29 04:16:39 UTC
Created attachment 17451 [details] [review]
0001-xfree86-return-an-error-if-Screen-is-missing-from-S.patch

Return an error when trying to parse the config file and no screen has been specified in the layout.
Comment 2 Julien Cristau 2008-06-30 09:11:02 UTC
> --- Comment #1 from Peter Hutterer <peter@cs.unisa.edu.au>  2008-06-29 04:16:39 PST ---
> Return an error when trying to parse the config file and no screen has been
> specified in the layout.
> 
can't we create a default Screen section (as in the autoconfig case) if
there isn't one in ServerLayout?
Comment 3 Peter Hutterer 2008-06-30 21:23:34 UTC
Created attachment 17469 [details] [review]
0001-xfree86-handle-missing-Screen-lines-in-the-ServerLa.patch

how about this one then?

If no Screen is specified in the ServerLayout section, either take the first
one from the config file or autogenerate a default screen.
Comment 4 Georgi Mirchev 2008-07-01 00:03:06 UTC
Comment on attachment 17469 [details] [review]
0001-xfree86-handle-missing-Screen-lines-in-the-ServerLa.patch

This patch has an obvious bug: The second "if" will never succeed.
Comment 5 Peter Hutterer 2008-07-01 00:57:59 UTC
> This patch has an obvious bug: The second "if" will never succeed.

are you referring to the second if (!count)?
count is modified in the while loop between the two hunks (and reset to 0
before that), so the condition that if count == 0 no screen was specified is
correct.
Comment 6 Georgi Mirchev 2008-07-01 03:50:43 UTC
I see. I was looking at the patch only.
Comment 7 Peter Hutterer 2008-07-03 06:28:50 UTC
pushed as fe5cf7cb00fd926cefff933adbdbceea7353f4c2

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.