Open lb90 opened 1 year ago
For reference, here's an actual stack trace which shows how libepoxy may end up calling egl functions without the system providing EGL:
#0 0x00007ff8c8eb3c0e in egl_provider_resolver (name=0x7ff8c8f04cf5 <entrypoint_strings+1333> "eglGetCurrentDisplay", providers=0x5fb8fe, entrypoints=0x5fb918) at src/egl_generated_dispatch.c:3677
#1 0x00007ff8c8eb4e4f in egl_single_resolver (provider=PROVIDER_EGL_10, entrypoint_offset=1333) at src/egl_generated_dispatch.c:3945
#2 0x00007ff8c8eb556d in epoxy_eglGetCurrentDisplay_resolver () at src/egl_generated_dispatch.c:4406
#3 0x00007ff8c8eb90ea in epoxy_eglGetCurrentDisplay_global_rewrite_ptr () at src/egl_generated_dispatch.c:5096
#4 0x00007ff8c8ec8777 in epoxy_conservative_egl_version () at ../libepoxy/src/dispatch_egl.c:33
#5 0x00007ff8c8eb3d64 in egl_provider_resolver_real (name=0x7ff8c8f04ce0 <entrypoint_strings+1312> "eglGetCurrentContext", providers=0x5fba6e, entrypoints=0x5fba88) at src/egl_generated_dispatch.c:3705
#6 0x00007ff8c8eb3bd2 in egl_provider_resolver (name=0x7ff8c8f04ce0 <entrypoint_strings+1312> "eglGetCurrentContext", providers=0x5fba6e, entrypoints=0x5fba88) at src/egl_generated_dispatch.c:3671
#7 0x00007ff8c8eb4e4f in egl_single_resolver (provider=PROVIDER_EGL_14, entrypoint_offset=1312) at src/egl_generated_dispatch.c:3945
#8 0x00007ff8c8eb5550 in epoxy_eglGetCurrentContext_resolver () at src/egl_generated_dispatch.c:4400
#9 0x00007ff8c8eb9064 in epoxy_eglGetCurrentContext_global_rewrite_ptr () at src/egl_generated_dispatch.c:5095
#10 0x00007ff8c8ec84d1 in epoxy_egl_get_current_gl_context_api () at ../libepoxy/src/dispatch_common.c:786
#11 0x00007ff8c8ec7dc7 in epoxy_is_desktop_gl () at ../libepoxy/src/dispatch_common.c:369
#12 0x00007ff8c8dd17b7 in gl_provider_resolver_real (name=0x7ff8c8eeef57 <entrypoint_strings+25879> "glGetStringi", providers=0x7ff8c8efdde0 <providers>, entrypoints=0x7ff8c8efdde8 <entrypoints>)
at src/gl_generated_dispatch.c:74183
#13 0x00007ff8c8dd1432 in gl_provider_resolver (name=0x7ff8c8eeef57 <entrypoint_strings+25879> "glGetStringi", providers=0x7ff8c8efdde0 <providers>, entrypoints=0x7ff8c8efdde8 <entrypoints>)
at src/gl_generated_dispatch.c:74129
#14 0x00007ff8c8de2f3b in epoxy_glGetStringi_resolver () at src/gl_generated_dispatch.c:89857
#15 0x00007ff8c8e35194 in epoxy_glGetStringi_dispatch_table_rewrite_ptr (name=7939, index=0) at src/gl_generated_dispatch.c:115712
#16 0x00007ff8c8e351e0 in epoxy_glGetStringi_dispatch_table_thunk (name=7939, index=0) at src/gl_generated_dispatch.c:115712
#17 0x00007ff8c8ec80f3 in epoxy_internal_has_gl_extension (ext=0x7ff8b83cc931 <buffers+729> "GL_GREMEDY_frame_terminator", invalid_op_mode=false) at ../libepoxy/src/dispatch_common.c:535
#18 0x00007ff8c8ec8190 in epoxy_has_gl_extension (ext=0x7ff8b83cc931 <buffers+729> "GL_GREMEDY_frame_terminator") at ../libepoxy/src/dispatch_common.c:619
The interesting frames are 10 & 11. Either we add epoxy_has_gl
checks before calling epoxy_egl_get_current_gl_context_api
, or we make it do the check and return EGL_NONE
.
Libepoxy may be built with support for EGL, but may run on trimmed-down systems which do not expose EGL. Or it may run in a sandbox which doesn't expose the EGL library. Check for EGL support at runtime before calling into EGL functions
Fixes https://gitlab.com/inkscape/inkscape/-/issues/4031