Commit 0eb0a816 by Kenneth Russell

Fix seg fault in IsPlatformAvailable.

Some GLX implementations can't handle having libGL.so.1 dlclose'd out from under them while there's any X window still open against which a GLXWindow was ever created. Load the library once per process rather than once per FunctionsGLX instance. This showed up as a crash in X11Window::destroy, during XCloseDisplay. BUG=angleproject:892 Change-Id: I0da2674786a952865e5bea2513259c0a32d4453c Reviewed-on: https://chromium-review.googlesource.com/280902Tested-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com>
parent 57cdc69c
......@@ -23,6 +23,8 @@
namespace rx
{
void* FunctionsGLX::sLibHandle = nullptr;
template<typename T>
static bool GetProc(PFNGETPROCPROC getProc, T *member, const char *name)
{
......@@ -88,7 +90,6 @@ struct FunctionsGLX::GLXFunctionTable
FunctionsGLX::FunctionsGLX()
: majorVersion(0),
minorVersion(0),
mLibHandle(nullptr),
mXDisplay(nullptr),
mXScreen(-1),
mFnPtrs(new GLXFunctionTable())
......@@ -107,17 +108,23 @@ bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorS
mXDisplay = xDisplay;
mXScreen = screen;
mLibHandle = dlopen("libGL.so.1", RTLD_NOW);
if (!mLibHandle)
// Some OpenGL implementations can't handle having this library
// handle closed while there's any X window still open against
// which a GLXWindow was ever created.
if (!sLibHandle)
{
*errorString = std::string("Could not dlopen libGL.so.1: ") + dlerror();
return false;
sLibHandle = dlopen("libGL.so.1", RTLD_NOW);
if (!sLibHandle)
{
*errorString = std::string("Could not dlopen libGL.so.1: ") + dlerror();
return false;
}
}
getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(mLibHandle, "glXGetProcAddress"));
getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(sLibHandle, "glXGetProcAddress"));
if (!getProc)
{
getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(mLibHandle, "glXGetProcAddressARB"));
getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(sLibHandle, "glXGetProcAddressARB"));
}
if (!getProc)
{
......@@ -212,11 +219,6 @@ bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorS
void FunctionsGLX::terminate()
{
if (mLibHandle)
{
dlclose(mLibHandle);
mLibHandle = nullptr;
}
}
bool FunctionsGLX::hasExtension(const char *extension) const
......
......@@ -73,7 +73,7 @@ class FunctionsGLX
struct GLXFunctionTable;
void *mLibHandle;
static void *sLibHandle;
Display *mXDisplay;
int mXScreen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment