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

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

Loading…
Cancel
Save