[Bf-committers] attempt to fix opengl query crashes under linux committed

erwin at erwincoumans.com erwin at erwincoumans.com
Thu Jul 6 23:46:07 CEST 2006


We fixed number 1 and 2 from the list below. Do we actually link with 
pthreads under linux? 

Can someone confirm things improved with latest CVS build? 

Thanks,
Erwin 

 

 

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: 

1  * 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.
2  * 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.
3  * 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. 



More information about the Bf-committers mailing list