Bug 22546 - GetGLXScreenConfigs() segfaults if GLX isn't present.
Summary: GetGLXScreenConfigs() segfaults if GLX isn't present.
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: GLX (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-29 17:39 UTC by David Korth
Modified: 2009-06-30 07:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch to fix GetGLXScreenConfigs(). (455 bytes, patch)
2009-06-29 17:39 UTC, David Korth
Details | Splinter Review

Description David Korth 2009-06-29 17:39:37 UTC
Created attachment 27243 [details] [review]
Patch to fix GetGLXScreenConfigs().

While testing rendering fallback functionality in an application that supports both OpenGL and software rendering, I discovered a bug in Mesa that causes the program to crash if it's running on an X server that doesn't support GLX at all (e.g. vncserver).

A backtrace reveals the source:

#0  GetGLXScreenConfigs (dpy=<value optimized out>, scrn=0) at glxcmds.c:167
        priv = (__GLXdisplayPrivate * const) 0x0
#1  0xb7a40fa7 in CreateContext (dpy=0x9c3ad98, vis=<value optimized out>, fbconfig=0x0, shareList=0x0, allowDirect=1, contextID=0, use_glx_1_3=0, 
    renderType=0) at glxcmds.c:364
        gc = (GLXContext) 0xb79e2ff4
        screen = -1208638311
        psc = <value optimized out>
#2  0xb7a415c0 in glXCreateContext (dpy=0x9c3ad98, vis=0x99ce4c0, shareList=0x0, allowDirect=1) at glxcmds.c:487

The GetGLXScreenConfigs() function is as follows:

static __GLXscreenConfigs *
GetGLXScreenConfigs(Display *dpy, int scrn)
{
    __GLXdisplayPrivate * const priv = __glXInitialize(dpy);

    return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
}

__glXInitialize() returns NULL because the X server doesn't support GLX; however, the following statement doesn't check if priv is NULL, which results in a null pointer dereference. The solution is to check both priv and priv->screenConfigs for NULL.

Mesa version is 7.5-rc4.
Comment 1 Brian Paul 2009-06-30 07:28:09 UTC
Fixed in git.  Commit d8cc32b7a5ba2588ce1a25c3838ebb4ee6c26e82


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.