tech-x11 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Xorg built with clang dumps core, with gcc not



On Sun, Feb 01, 2015 at 03:17:39PM +0100, Thomas Klausner wrote:
> On Sun, Feb 01, 2015 at 02:45:08PM +0100, Thomas Klausner wrote:
> > On Sun, Feb 01, 2015 at 11:00:01AM +0100, Thomas Klausner wrote:
> > > Hi!
> > > 
> > > I'm seeing strange behaviour. I've updated to 7.99.4 from yesterday
> > > and tried a build with clang as default compiler, i.e. "-V MKLLVM=yes
> > > -V HAVE_LLVM=yes -V MKGCC=no" in my build.sh command line.
> > > 
> > > When I installed that kernel and userland, starting X just gave me a
> > > black screen and I couldn't switch back to console; i.e. X probably
> > > just died.
> > > 
> > > Xorg.0.log contains:
> > > ...
> > > (==) Log file: "/var/log/Xorg.0.log", Time: Sat Jan 31 21:26:07 2015
> > > (==) Using config file: "/etc/X11/xorg.conf"
> > > (II) [KMS] Kernel modesetting enabled.
> > > (EE) RADEON(0): Cannot position output DVI-0 relative to unknown output Left Monitor
> > > The XKEYBOARD keymap compiler (xkbcomp) reports:
> > > > Error:            Couldn't lookup keysym
> > > >                   Symbol interpretation ignored
> > > > Error:            Couldn't lookup keysym
> > > >                   Symbol interpretation ignored
> > > Errors from xkbcomp are not fatal to the X server
> > > Can't open display :0
> > > ...
> > > 
> > > Then I tried building the same sources with gcc as compiler, and X
> > > works. Xorg.0.log:
> > > ...
> > > (==) Log file: "/var/log/Xorg.1.log", Time: Sat Jan 31 21:26:59 2015
> > > (==) Using config file: "/etc/X11/xorg.conf"
> > > (II) [KMS] Kernel modesetting enabled.
> > > (EE) RADEON(0): Cannot position output DVI-0 relative to unknown output Left Monitor
> > > The XKEYBOARD keymap compiler (xkbcomp) reports:
> > > > Error:            Couldn't lookup keysym
> > > >                   Symbol interpretation ignored
> > > > Error:            Couldn't lookup keysym
> > > >                   Symbol interpretation ignored
> > > Errors from xkbcomp are not fatal to the X server
> > > xrandr: cannot find mode 1920x1200
> > > X Error of failed request:  BadValue (integer parameter out of range for operation)
> > >   Major opcode of failed request:  118 (X_SetModifierMapping)
> > >   Value in failed request:  0x17
> > >   Serial number of failed request:  15
> > >   Current serial number in output stream:  15
> > > 2015-01-31 21:27:00 INFO  /notion/../ioncore.c:609: ioncore_startup: Starting Notion
> > > ...
> > > 
> > > This even works with the kernel built with clang (i.e. gcc /usr/X11R7
> > > on top of clang /netbsd).
> > > 
> > > When I start /usr/X11R7/bin/Xorg in gdb (as root), the clang-built X
> > > works: I can start xterms and a window manager.
> > > 
> > > Then I noticed that starting X (using startx) as my user gives me an
> > > Xorg.core file (I thought it didn't do that for setuid root files?!).
> > > Here's the backtrace:
> > > 
> > > Program terminated with signal SIGSEGV, Segmentation fault.
> > > #0  radeon_dri2_unref_buffer (buffer=0x1) at /archive/foreign/xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri2.c:584
> > > 584             struct dri2_buffer_priv *private = buffer->driverPrivate;
> > > (gdb) bt
> > > #0  radeon_dri2_unref_buffer (buffer=0x1) at /archive/foreign/xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri2.c:584
> > > #1  radeon_dri2_client_state_changed (ClientStateCallback=0x8591a0 <ClientStateCallback>, data=0x0, calldata=<optimized out>)
> > >     at /archive/foreign/xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri2.c:610
> > > #2  0x000000000046dbdc in _CallCallbacks (pcbl=0x8591a0 <ClientStateCallback>, call_data=0x7f7fffffd3b0)
> > >     at /archive/foreign/xsrc/external/mit/xorg-server/dist/dix/dixutils.c:742
> > > #3  0x0000000000453ea1 in CallCallbacks (pcbl=<optimized out>, call_data=0x0) at /archive/build/amd64.clang.20150131/usr/X11R7/include/xorg/callback.h:86
> > > #4  CloseDownClient (client=0x7f7ff5fcda10) at /archive/foreign/xsrc/external/mit/xorg-server/dist/dix/dispatch.c:3461
> > > #5  0x0000000000453cb7 in Dispatch () at /archive/foreign/xsrc/external/mit/xorg-server/dist/dix/dispatch.c:416
> > > #6  0x000000000042e417 in main (argc=1, argv=0x7f7fffffd4c8, envp=<optimized out>) at /archive/foreign/xsrc/external/mit/xorg-server/dist/dix/main.c:287
> > > (gdb)
> > > 
> > > 
> > > I'm not sure what could be the cause of this. My latest idea is that
> > > the failed request in the gcc log somehow kills the clang X, perhaps
> > > because some data structures are packed differently (just guessing).
> > > 
> > > Does anyone have an idea?
> > 
> > 
> > joerg had the idea of trying with a radeon driver built with -O0, and
> > that does indeed fix the problem.
> > 
> > I.e., radeon_drv.so.6 build with -O2 breaks, -O0 works.
> 
> It's mostly radeon_dri2.pico -- when I build this with -O2, it breaks,
> when I build it with -O0, it works.

Using this kind of trick:

-radeon_dri2_client_state_changed(CallbackListPtr *ClientStateCallback, pointer data, pointer calldata)
+radeon_dri2_client_state_changed(CallbackListPtr *ClientStateCallback, pointer data, pointer calldata) __attribute__((optnone))

I've tracked it down to this function in that file.

The function is rather short:

static void
radeon_dri2_client_state_changed(CallbackListPtr *ClientStateCallback, pointer data, pointer calldata) __attribute__((optnone))
{
    DRI2ClientEventsPtr pClientEventsPriv;
    DRI2FrameEventPtr ref;
    NewClientInfoRec *clientinfo = calldata;
    ClientPtr pClient = clientinfo->client;
    pClientEventsPriv = GetDRI2ClientEvents(pClient);

    switch (pClient->clientState) {
    case ClientStateInitial:
        xorg_list_init(&pClientEventsPriv->reference_list);
        break;
    case ClientStateRunning:
        break;

    case ClientStateRetained:
    case ClientStateGone:
        if (pClientEventsPriv) {
            xorg_list_for_each_entry(ref, &pClientEventsPriv->reference_list, link) {
                ref->valid = FALSE;
                radeon_dri2_unref_buffer(ref->front);
                radeon_dri2_unref_buffer(ref->back);
            }
        }
        break;
    default:
        break;
    }
}

and I suspect the xorg_list_for_each_entry, which expands to:

        if (pClientEventsPriv) {
            for (ref = (void *)((char *)((&pClientEventsPriv->reference_list)->next) - ((char *)&(ref)->link - (char *)(ref))); &ref->link != (&pClientEventsPriv->reference_list); ref = (void *)((char *)(ref->link.next) - ((char *)&(ref)->link - (char *)(ref)))) {
                ref->valid = 0;
                radeon_dri2_unref_buffer(ref->front);
                radeon_dri2_unref_buffer(ref->back);
            }
        }

Anyway, that is not the only source of problems, when I start mpv to
play a movie, X segfaults too. Perhaps it has the same underlying
cause, so I'll be waiting for now, until this issue is fixed first.
 Thomas


Home | Main Index | Thread Index | Old Index