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. 13
      src/dispatch_common.c
  2. 2
      test/Makefile.am

@ -435,17 +435,20 @@ epoxy_get_bootstrap_proc_address(const char *name)
EGLenum save_api = eglQueryAPI();
EGLContext ctx;
eglBindAPI(EGL_OPENGL_API);
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);
if (eglBindAPI(EGL_OPENGL_ES_API)) {
ctx = eglGetCurrentContext();
if (ctx) {
eglBindAPI(save_api);
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
@ -457,7 +460,9 @@ epoxy_get_bootstrap_proc_address(const char *name)
else
return epoxy_gles1_dlsym(name);
}
eglBindAPI(save_api);
} else {
(void)eglGetError();
}
}
#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