On non-hybris device, libhybris crashes inside eglGetDisplay("EGL_DEFAULT_DISPLAY")
The following program crashes when executed on a system which doesn't have Halium environment but have libhybris's libEGL implementation installed (e.g. pulled by QtWebEngine):
#include <EGL/egl.h>
int main() {
eglGetDisplay(EGL_DEFAULT_DISPLAY);
return 0;
}
I get this stacktrace:
(gdb) bt
#0 __tls_get_addr (ti=0x7ffff7910e78) at bionic/libc/bionic/bionic_elf_tls.cpp:349
#1 0x00007ffff78d8478 in strlcpy (__n=512, __src=0x7ffff7901d7a "dlopen failed", __dest=<optimized out>)
at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:157
#2 __bionic_format_dlerror (detail=0x7ffff79120a0 <__linker_dl_err_buf> "", msg=0x7ffff7901d7a "dlopen failed")
at /build/libhybris-0.1.0+git20250630+0cedf90/hybris/common/q/dlfcn.cpp:121
#3 dlopen_ext (filename=<optimized out>, flags=1, extinfo=<optimized out>, caller_addr=0x7ffff7cd1cf0 <_init_androidegl()+64>)
at /build/libhybris-0.1.0+git20250630+0cedf90/hybris/common/q/dlfcn.cpp:153
#4 0x00007ffff7cd1cf0 in _init_androidegl () at /build/libhybris-0.1.0+git20250630+0cedf90/hybris/egl/egl.c:85
#5 0x00007ffff7cd3247 in hybris_egl_initialize () at /build/libhybris-0.1.0+git20250630+0cedf90/hybris/egl/egl.c:91
#6 eglGetProcAddress (procname=0x7ffff7fb2791 "eglInitialize") at /build/libhybris-0.1.0+git20250630+0cedf90/hybris/egl/egl.c:593
So, 1.) Bionic's __tls_get_addr()
, be it from libhybris itself or from Halium, should not be called at all. So this is wrong and points to "recent" libhybris' TLS enablement.
But, 2.) WHY in the world does See #21 (comment 2690404899)strlcpy()
call into __tls_get_addr()
??? Apparently this is related to fortified string functions (and the referenced file is here), but I see nothing related to TLS at all.
Edited by Ratchanan Srirattanamet