about summary refs log tree commit diff
path: root/elf/tst-tls19mod3.c
diff options
context:
space:
mode:
authorMartin von Gagern <Martin.vGagern@gmx.net>2011-05-14 21:25:43 -0400
committerUlrich Drepper <drepper@gmail.com>2011-05-14 21:25:43 -0400
commitd26dfc60edc8c6dd160eefff16a734152a835ca0 (patch)
tree0d0e1a3caa1f5edd8fc27a8a4715fc1052740c7e /elf/tst-tls19mod3.c
parenta79a1c704b32c48903a4cb4c0786eca828520b5c (diff)
downloadglibc-d26dfc60edc8c6dd160eefff16a734152a835ca0.tar.gz
glibc-d26dfc60edc8c6dd160eefff16a734152a835ca0.tar.xz
glibc-d26dfc60edc8c6dd160eefff16a734152a835ca0.zip
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.
Diffstat (limited to 'elf/tst-tls19mod3.c')
-rw-r--r--elf/tst-tls19mod3.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/elf/tst-tls19mod3.c b/elf/tst-tls19mod3.c
new file mode 100644
index 0000000000..e7b28016b3
--- /dev/null
+++ b/elf/tst-tls19mod3.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+static int __thread tbaz __attribute__ ((tls_model ("local-dynamic"))) = 42;
+
+void
+setter2 (int a)
+{
+  tbaz = a;
+}
+
+int
+baz (void)
+{
+  printf ("&tbaz=%p\n", &tbaz);
+  return tbaz;
+}