initial-exec TLS model breaks dlopen'ed libGL
Submitted by Christopher James Halse Rogers
Assigned to mes..@..op.org
Description
Created attachment 44411 Source and Makefile for trivial SIGSEGV reproducer.
Mesa's use of the initial-exec TLS model unpredictably breaks usage of libGL by programs for which the executable isn't directly linked to libGL (so, python apps, mono apps, C apps which use dlopen, etc).
This manifests as a SIGSEGV in libstdc++ when certain conditions are met (stream output and exception handling seem to be examples of this).
Attached is a trivial example program which demonstrates the crash. (Thanks to Ulrich von Zadow on the associated Ubuntu bug²).
According to the linux TLS ABI reference¹ I could find, initial-exec implies a the static TLS model, which doesn't work for dynamically loaded modules. However, checking out the dl-tls.c code in eglibc there seems to be some attempt to handle this. Also, the TLS ABI reference suggests that __tls_get_addr receives its parameter in %eax, but this doesn't appear to be the case in dl-tls.c.
¹: http://www.akkadia.org/drepper/tls.pdf ²: https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/259219
Attachment 44411, "Source and Makefile for trivial SIGSEGV reproducer.":
ldpreload_crash.zip
Version: git