Load ANGLEResetDisplayPlatform via dlsym
... which is slightly more defensive than loading the function via
eglGetProcAddress. When loading the function via eglGetProcAdress,
the returned function pointer will be one of the ext forwardering
helpers (__glExtFwd0 in this observed case). The process can then
crash if eglTerminate() is called on a new thread that has not yet
called eglMakeCurrent() where the thread local gl_hooks_t is 0x0.
Bug: b/181162754
Test: HeifWriterTest on Cuttlefish w/ SwANGLE
Change-Id: Ia8e55c899f9fde91215ce75313b33517f8440fee
diff --git a/opengl/libs/EGL/egl_angle_platform.cpp b/opengl/libs/EGL/egl_angle_platform.cpp
index dc8e587..c29181d 100644
--- a/opengl/libs/EGL/egl_angle_platform.cpp
+++ b/opengl/libs/EGL/egl_angle_platform.cpp
@@ -129,8 +129,8 @@
return false;
}
- angleResetDisplayPlatform = reinterpret_cast<ResetDisplayPlatformFunc>(
- eglGetProcAddress("ANGLEResetDisplayPlatform"));
+ angleResetDisplayPlatform =
+ reinterpret_cast<ResetDisplayPlatformFunc>(dlsym(so, "ANGLEResetDisplayPlatform"));
PlatformMethods* platformMethods = nullptr;
if (!((angleGetDisplayPlatform)(dpy, g_PlatformMethodNames, g_NumPlatformMethods, nullptr,