Catch eglBindAPI() failures in looking up bootstrap functions.

This fixes crashes on ARM's Mali drivers, where desktop GL isn't
supported, and epoxy didn't notice the error and tried to dlsym() on
libGL.so.1.

An alternative would have been to look at the response from
eglQueryAPI() first, but that would have meant that we still need to
BindAPI in the case that eglQueryAPI returns something like VG or CL,
and so we needed to handle these errors regardless.

Fixes #22
macos/v1.5.9
Eric Anholt 11 years ago
parent f15c169cad
commit 53b87c33e4
  1. 43
      src/dispatch_common.c
  2. 2
      test/Makefile.am

@ -435,29 +435,34 @@ epoxy_get_bootstrap_proc_address(const char *name)
EGLenum save_api = eglQueryAPI();
EGLContext ctx;
eglBindAPI(EGL_OPENGL_API);
ctx = eglGetCurrentContext();
if (ctx) {
eglBindAPI(save_api);
return epoxy_gl_dlsym(name);
if (eglBindAPI(EGL_OPENGL_API)) {
ctx = eglGetCurrentContext();
if (ctx) {
eglBindAPI(save_api);
return epoxy_gl_dlsym(name);
}
} else {
(void)eglGetError();
}
eglBindAPI(EGL_OPENGL_ES_API);
ctx = eglGetCurrentContext();
if (ctx) {
if (eglBindAPI(EGL_OPENGL_ES_API)) {
ctx = eglGetCurrentContext();
eglBindAPI(save_api);
/* We can't resolve the GL version, because
* epoxy_glGetString() is one of the two things calling
* us. Try the GLES2 implementation first, and fall back
* to GLES1 otherwise.
*/
get_dlopen_handle(&api.gles2_handle, "libGLESv2.so.2", false);
if (api.gles2_handle)
return epoxy_gles2_dlsym(name);
else
return epoxy_gles1_dlsym(name);
if (ctx) {
/* We can't resolve the GL version, because
* epoxy_glGetString() is one of the two things calling
* us. Try the GLES2 implementation first, and fall back
* to GLES1 otherwise.
*/
get_dlopen_handle(&api.gles2_handle, "libGLESv2.so.2", false);
if (api.gles2_handle)
return epoxy_gles2_dlsym(name);
else
return epoxy_gles1_dlsym(name);
}
} else {
(void)eglGetError();
}
eglBindAPI(save_api);
}
#endif /* PLATFORM_HAS_EGL */

@ -60,8 +60,6 @@ TESTS = \
$()
XFAIL_TESTS = \
egl_gles1_without_glx \
egl_gles2_without_glx \
$()
check_PROGRAMS = $(TESTS)

Loading…
Cancel
Save