[Bf-committers] Re: Game engine crashes in Linux ->buggy combo of pthread, libGL.so and dlopen()

erwin at erwincoumans.com erwin at erwincoumans.com
Thu Jul 6 21:14:44 CEST 2006


A quick google session shows the combination pthreads / dlopen/libGL.so  and 
nvidia/ati drivers are causing crashes with lots of games, including DOOM3 
etc. 

from http://dri.sourceforge.net/doc/DRIuserguide.html
"
11.5 libGL.so and dlopen() 

A number of popular OpenGL applications on Linux (such as Quake3, HereticII, 
Heavy Gear 2, etc) dynamically open the libGL.so library at runtime with 
dlopen(), rather than linking with -lGL at compile/link time. 

If dynamic loading of libGL.so is not implemented carefully, there can be a 
number of serious problems. Here are the things to be careful of in your 
application: 

   * Specify the RTLD_GLOBAL flag to dlopen(). If you don't do this then 
you'll likely see a runtime error message complaining that _glapi_Context is 
undefined when libGL.so tries to open a hardware-specific driver. Without 
this flag, nested opening of dynamic libraries does not work.
   * Do not close the library with dlclose() until after XCloseDisplay() has 
been called. When libGL.so initializes itself it registers several callbacks 
functions with Xlib. When XCloseDisplay() is called those callback functions 
are called. If libGL.so has already been unloaded with dlclose() this will 
cause a segmentation fault.
   * Your application should link with -lpthread. On Linux, libGL.so uses 
the pthreads library in order to provide thread safety. There is apparently 
a bug in the dlopen()/dlclose() code which causes crashes if the library 
uses pthreads but the parent application doesn't. The only known work-around 
is to link the application with -lpthread. 

Some applications don't yet incorporate these procedures and may fail. For 
example, changing the graphics settings in some video games will expose this 
problem. The DRI developers are working with game vendors to prevent this 
problem in the future. " 


http://www.nvnews.net/vbulletin/showthread.php?t=47728
http://www.nvnews.net/vbulletin/showthread.php?t=61468 

>From 
http://download.nvidia.com/XFree86/Linux-x86/1.0-8174/README/32bit_html/chap 
ter-05.html
:
"The dynamic loader on your system has a bug which will cause applications 
linked with pthreads, and that dlopen() libGL multiple times, to crash." 

Erwin 

 


erwin at erwincoumans.com writes: 

> 
> I asked Charlie to have a look at it. Unfortunately I can't reproduce.
> Can anyone reproduce and give a longer call stack, perhaps in debug mode?  
> 
> Installing new drivers and making a symbolic link to libGL.so usually 
> works, but it should never crash.  
> 
> Thanks,
> Erwin  
> 
> 
> Ton Roosendaal writes:  
> 
>> Hi,  
>> 
>> Several different users report a crash in the code that detects opengl  
>> options:  
>> 
>> ....
>> Detected GL_ARB_texture_env_combine
>> Detected GL_ARB_texture_cube_map
>> Segmentation fault  
>> 
>> It is in:
>> Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp  
>> 
>> Who here can redo this crash for a decent stacktrace or even a solution?  
>> 
>> Tracker:
>> http://projects.blender.org/tracker/index.php? 
>> func=detail&aid=4621&group_id=9&atid=125  
>> 
>> 
>> -Ton-  
>> 
>> ------------------------------------------------------------------------ 
>> --
>> Ton Roosendaal  Blender Foundation ton at blender.org  
>> http://www.blender.org  
>> 
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-committers
>  
> 
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
 



More information about the Bf-committers mailing list