When dri_glx.c:OpenDisplay is called for a driver that is already loaded the function returns a pointer to the library without incrementing its reference count. This can come from nested calls in one thread or from multiple threads within a process. Unfortunately the first close works its way down to the dlclose in driDestroyDisplay and the library is unloaded which invalidates other references to its contents.
The attached patch amends the function to bump the reference count for driver libraries before returning a pointer to them.
Created attachment 12970 [details] [review]
Pushed to Git, thanks.
Mass version move, cvs -> git