From d26dfc60edc8c6dd160eefff16a734152a835ca0 Mon Sep 17 00:00:00 2001 From: Martin von Gagern Date: Sat, 14 May 2011 21:25:43 -0400 Subject: Fix handling of static TLS in dlopen'ed objects When dynamically loading a library along with several dependencies, calls to _dl_add_to_slotinfo and _dl_update_slotinfo can become intermixed. As a consequence, _dl_update_slotinfo will update the generation counter of the dtv although not all of the slots belonging to that generation have been added. Subsequent calls to _dl_add_to_slotinfo will add more slots to the same generation, for which no storage will be allocated, as the dtv generation checks will claim no work is necessary. This will lead to uninitialized dtv entries and will likely cause a SIGSEGV when thread local variables are accessed. --- elf/tst-tls19.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 elf/tst-tls19.c (limited to 'elf/tst-tls19.c') diff --git a/elf/tst-tls19.c b/elf/tst-tls19.c new file mode 100644 index 0000000000..acbc1d6964 --- /dev/null +++ b/elf/tst-tls19.c @@ -0,0 +1,27 @@ +// BZ 12453 +#include +#include + + +static int +do_test (void) +{ + void* dl = dlopen ("tst-tls19mod1.so", RTLD_LAZY | RTLD_GLOBAL); + if (dl == NULL) + { + printf ("Error loading tst-tls19mod1.so: %s\n", dlerror ()); + return 1; + } + + int (*fn) (void) = dlsym (dl, "foo"); + if (fn == NULL) + { + printf("Error obtaining symbol foo\n"); + return 1; + } + + return fn (); +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" -- cgit 1.4.1