Re: Segmentation fault in "Fake_glXUseXFont" (Mesa 10.4.3)
Brian Paul <[email protected]>
| Newsgroups | gmane.comp.video.mesa3d.user |
|---|---|
| Message-ID | <[email protected]> |
On 02/25/2015 08:18 AM, Martin Knoblauch wrote: > Hi, > > in a customer project I am facing an awkward situation. We need to run > a "closed source 3rd party interactive OpenGL application with 'not very > good support'" (I cannot and do not want to name the App) on a server > machine with no dedicated GFX hardware. > > The plan is to run it with Mesa OpenGL and a Xvfb X server. > > This mostly works OK, but we are seeing consistent segmentation faults > whenever "glXUseFont" is called. The core dumps come from line the > following lines in the "Fake_glXUseXFont" routine: > > dpy = glXGetCurrentDisplay(); > if (!dpy) > return; /* I guess glXMakeCurrent > wasn't called */ > core ==> win = RootWindow(dpy, DefaultScreen(dpy)); > > So the call to "glXGetCurrentDisplay" returns non-null, but the > structure behind the pointer seems invalid. I added some debugging > output, and that shows that the "number of screens" for that display is > 0, which explains the failure in the RootWindow macro. > > Now the questions are: > > 1) how cant that happen > 2) what can be done OK, I just reproduced the issue here. I think it's been broken for a long time. Can you try the attached Mesa patch? > > The server is running SLES11SP2 and Mesa has been build with the > following configure options: > > $ ./configure --enable-driglx-direct --enable-xlib-glx --disable-dri > --disable-xvmc --disable-egl --with-gallium-drivers= I'd omit --enable-driglx-direct, that seems in conflict with wanting to use Xlib rather than DRI. -Brian _______________________________________________ mesa-users mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-users
0001-xlib-fix-some-broken-GLX-functions.patch
(text/x-patch, 5.7 KB)
From d85e120250fe4678891384b3d9055f8b7f564318 Mon Sep 17 00:00:00 2001 From: Brian Paul <[email protected]> Date: Wed, 25 Feb 2015 09:16:02 -0700 Subject: [PATCH] xlib: fix some broken GLX functions Calling glXGetCurrentDisplay(), glXGetCurrentDrawable() or glXGetCurrentReadDrawable() returned garbage. This also caused functions like glXUseXFont() to fail. Get rid of the old __GLXContext type and plumb the above functions down to corresponding XMesa functions. Fixes issue reported by Martin Knoblauch on mesa-users list. Cc: "10.5, 10.4" <[email protected]> --- src/mesa/drivers/x11/glxapi.c | 19 +++++++------------ src/mesa/drivers/x11/glxapi.h | 14 -------------- src/mesa/drivers/x11/xfonts.c | 3 ++- src/mesa/drivers/x11/xm_api.c | 37 +++++++++++++++++++++++++++++++++++++ src/mesa/drivers/x11/xmesa.h | 10 ++++++++++ 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c index a870e94..9399a5e 100644 --- a/src/mesa/drivers/x11/glxapi.c +++ b/src/mesa/drivers/x11/glxapi.c @@ -38,6 +38,7 @@ #include "main/compiler.h" #include "glapi/glapi.h" #include "glxapi.h" +#include "xmesa.h" extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); @@ -229,9 +230,6 @@ glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value) } -/* declare here to avoid including xmesa.h */ -extern void *XMesaGetCurrentContext(void); - GLXContext PUBLIC glXGetCurrentContext(void) { @@ -242,8 +240,7 @@ glXGetCurrentContext(void) GLXDrawable PUBLIC glXGetCurrentDrawable(void) { - __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext(); - return gc ? gc->currentDrawable : 0; + return XMesaGetCurrentDrawable(); } @@ -382,10 +379,7 @@ glXQueryServerString(Display *dpy, int screen, int name) Display PUBLIC * glXGetCurrentDisplay(void) { - /* Same code as in libGL's glxext.c */ - __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext(); - if (NULL == gc) return NULL; - return gc->currentDpy; + return XMesaGetCurrentDisplay(); } @@ -483,8 +477,7 @@ glXDestroyWindow(Display *dpy, GLXWindow window) GLXDrawable PUBLIC glXGetCurrentReadDrawable(void) { - __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext(); - return gc ? gc->currentReadable : 0; + return XMesaGetCurrentReadDrawable(); } @@ -679,7 +672,9 @@ glXFreeContextEXT(Display *dpy, GLXContext context) GLXContextID PUBLIC glXGetContextIDEXT(const GLXContext context) { - return ((__GLXcontext *) context)->xid; + /* We have no XID for Mesa's fake GLX contexts */ + fprintf(stderr, "Mesa: glXGetContextIDEXT not supported\n"); + return 0; } Display PUBLIC * diff --git a/src/mesa/drivers/x11/glxapi.h b/src/mesa/drivers/x11/glxapi.h index bd6e970..a7622a8 100644 --- a/src/mesa/drivers/x11/glxapi.h +++ b/src/mesa/drivers/x11/glxapi.h @@ -31,20 +31,6 @@ #include "GL/glx.h" -/* The GLX API dispatcher (i.e. this code) is being built into stand-alone - * Mesa. We don't know anything about XFree86 or real GLX so we define a - * minimal __GLXContextRec here so some of the functions in this file can - * work properly. - */ -typedef struct __GLXcontextRec { - Display *currentDpy; - GLboolean isDirect; - GLXDrawable currentDrawable; - GLXDrawable currentReadable; - XID xid; -} __GLXcontext; - - /* * Almost all the GLX API functions get routed through this dispatch table. * The exceptions are the glXGetCurrentXXX() functions. diff --git a/src/mesa/drivers/x11/xfonts.c b/src/mesa/drivers/x11/xfonts.c index e9a38ba..f7a80f0 100644 --- a/src/mesa/drivers/x11/xfonts.c +++ b/src/mesa/drivers/x11/xfonts.c @@ -225,7 +225,8 @@ Fake_glXUseXFont(Font font, int first, int count, int listbase) dpy = glXGetCurrentDisplay(); if (!dpy) return; /* I guess glXMakeCurrent wasn't called */ - win = RootWindow(dpy, DefaultScreen(dpy)); + i = DefaultScreen(dpy); + win = RootWindow(dpy, i); fs = XQueryFont(dpy, font); if (!fs) { diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 89c219e..f1bd8a8 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1276,6 +1276,19 @@ XMesaContext XMesaGetCurrentContext( void ) } +Display *XMesaGetCurrentDisplay(void) +{ + GET_CURRENT_CONTEXT(ctx); + if (ctx) { + XMesaContext xmesa = XMESA_CONTEXT(ctx); + return xmesa->display; + } + else { + return NULL; + } +} + + XMesaBuffer XMesaGetCurrentBuffer( void ) { GET_CURRENT_CONTEXT(ctx); @@ -1302,6 +1315,30 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void ) } +GLXDrawable XMesaGetCurrentDrawable(void) +{ + XMesaBuffer xmbuffer = XMesaGetCurrentBuffer(); + if (xmbuffer) { + struct xmesa_renderbuffer *front = xmbuffer->frontxrb; + if (front) + return front->drawable; + } + return 0; +} + + +GLXDrawable XMesaGetCurrentReadDrawable(void) +{ + XMesaBuffer xmbuffer = XMesaGetCurrentReadBuffer(); + if (xmbuffer) { + struct xmesa_renderbuffer *front = xmbuffer->frontxrb; + if (front) + return front->drawable; + } + return 0; +} + + GLboolean XMesaSetFXmode( GLint mode ) { diff --git a/src/mesa/drivers/x11/xmesa.h b/src/mesa/drivers/x11/xmesa.h index b6a2576..ad81031 100644 --- a/src/mesa/drivers/x11/xmesa.h +++ b/src/mesa/drivers/x11/xmesa.h @@ -228,11 +228,21 @@ extern XMesaContext XMesaGetCurrentContext( void ); /* + * Return Display * for currently bound context. + */ +extern Display *XMesaGetCurrentDisplay(void); + + +/* * Return handle to the current (draw) buffer. */ extern XMesaBuffer XMesaGetCurrentBuffer( void ); +extern GLXDrawable XMesaGetCurrentDrawable(void); +extern GLXDrawable XMesaGetCurrentReadDrawable(void); + + /* * Return handle to the current read buffer. * New in Mesa 3.3 -- 1.9.1