Bug 2460 - X server fails on PowerPC when built with GCC 4.7.x
Summary: X server fails on PowerPC when built with GCC 4.7.x
Status: VERIFIED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: 1.2
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.3 M1
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks: 1477
  Show dependency tree
 
Reported: 2012-05-15 17:06 UTC by Gary Thomas
Modified: 2012-06-20 06:25 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments
Fix incorrect stack variable usage (7.31 KB, patch)
2012-05-15 22:00 UTC, Gary Thomas
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Thomas 2012-05-15 17:06:05 UTC
If I build from this configuration:
Build Configuration:
BB_VERSION        = "1.15.2"
TARGET_ARCH       = "powerpc"
TARGET_OS         = "linux"
MACHINE           = "qemuppc"
DISTRO            = "poky"
DISTRO_VERSION    = "1.2+snapshot-20120515"
TUNE_FEATURES     = "m32 fpu-hard ppc603e"
TARGET_FPU        = ""
meta              
meta-yocto        = "master:12b4543ac9f54c0db0ee4a7ee546a71946a051f8"

build 'core-image-sato'

Using the default GCC 4.7.x, the X server fails with this error:
  Fatal server error:
  no screens found

Rebuild (the whole thing!) using GCC 4.6.x by specifying
  GCCVERSION = "4.6%"
and no other changes.  With this configuration, X works fine.

I've duplicated this on both qemuppc and my own PowerPC machines.
I've not net delved into the why...
Comment 1 Gary Thomas 2012-05-15 21:58:54 UTC
The problem boils down to code that looks like this:

   void *ptr;
   switch(XX) {
      case a:
         define_some_structure A;
         ptr = &A;
         break;
      case b:
         define_some_structure B;
         ptr = &B;
         break;
   }
   call_some_function(ptr);

The data in the structure (either A or B) is being destroyed or lost
somewhere in this process, hence the function may fail.

IMO, this is should not be legal (if it even is, I'm not a C spec expert),
even if it has been around and working for 25 years :-(

The attached patch fixes this bug and the X server runs again.  That said,
who knows how many other such dragons are left to be discovered.
Comment 2 Gary Thomas 2012-05-15 22:00:01 UTC
Created attachment 513 [details]
Fix incorrect stack variable usage
Comment 3 Khem Raj 2012-05-16 18:17:44 UTC
(In reply to comment #2)
> Created attachment 513 [details]
> Fix incorrect stack variable usage

this patch is OK FWIW I think gcc 4.7 kills the locals once it goes out of scope
i.e. switch {}

I wonder if you get warnings about it from gcc
Comment 4 Gary Thomas 2012-05-16 18:26:15 UTC
There are no warnings about this in the build log.

Per discussion with Martin Jansa, I've proposed (oe-core list) to bring in an upstream fix from 2010-08-10 (which tells you how stale this recipe is...)
  http://cgit.freedesktop.org/xorg/xserver/patch/Xext/xace.c?id=6dae7f3792611aace1df0cca63bf50c50d93de43
Comment 5 Andrei Gherzan 2012-05-20 21:14:47 UTC
Merged in master.

commit 6d40b658f42837f4270f1dd3c0f350eb84b369f0
Author: Gary Thomas <gary@mlbassoc.com>
Date:   Fri May 18 17:18:18 2012 +0300
Comment 6 Laurentiu Serban 2012-06-20 06:25:22 UTC
Verified