[Mesa-dev] [PATCH] glx: Don't uselessly dlopen libGL within libGL

Ian Romanick idr at freedesktop.org
Thu May 29 15:10:36 PDT 2014


On 05/29/2014 10:47 AM, Adam Jackson wrote:
> This is entirely pointless.  The DRI driver does not need any symbols
> from libGL, even if it did libGL would already be available to resolve
> them because that's how dlopen works.

That code was originally added by:

commit 061a3fe34051327fba418cc99599ecff0016ee15
Author: Michel Dänzer <michel at daenzer.net>
Date:   Mon Aug 14 15:53:37 2006 +0000

    Bug #7169: Attempt to make libGL symbols visible to drivers.
    
    Some applications end up dlopening libGL without RTLD_GLOBAL, so the libGL
    symbols referenced by the driver can't be unresolved when libGL dlopens it.
    This attempts to make the libGL symbols visible to the driver by dlopening
    libGL (again) with RTLD_GLOBAL before dlopening the driver and dlclosing
    the obtained handle afterwards.

So... I think that's not how dlopen always works.  For other reasons, I
don't think the DRI drivers directly access symbols from libGL, so this
may be safe anyway.  I'd want to see it tested, though.

> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  src/glx/dri_common.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
> index e5a3f70..235d350 100644
> --- a/src/glx/dri_common.c
> +++ b/src/glx/dri_common.c
> @@ -93,14 +93,11 @@ dri_message(int level, const char *f, ...)
>  _X_HIDDEN void *
>  driOpenDriver(const char *driverName)
>  {
> -   void *glhandle, *handle;
> +   void *handle;
>     const char *libPaths, *p, *next;
>     char realDriverName[200];
>     int len;
>  
> -   /* Attempt to make sure libGL symbols will be visible to the driver */
> -   glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_LOCAL);
> -
>     libPaths = NULL;
>     if (geteuid() == getuid()) {
>        /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
> @@ -146,9 +143,6 @@ driOpenDriver(const char *driverName)
>     if (!handle)
>        ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
>  
> -   if (glhandle)
> -      dlclose(glhandle);
> -
>     return handle;
>  }
>  



More information about the mesa-dev mailing list