[RFC][patch] Fix racy nptl/tst-getpid2
Paul Pluzhnikov
ppluzhnikov@google.com
Mon Oct 1 18:32:00 GMT 2012
Greetings,
The nptl/tst-getpid2 failed on one of our nightly builders, and we've
discovered that it is quite flaky:
build=$PWD
j=0;
while GCONV_PATH=$build/iconvdata LC_ALL=C \
$build/elf/ld-linux-x86-64.so.2 --library-path $build:$build/nptl \
$build/nptl/tst-getpid2 > /dev/null; do
j=$(($j+1))
done;
echo "failed after $j iterations"
Didn't expect signal from child: got `Illegal instruction'
failed after 140 iterations
Didn't expect signal from child: got `Illegal instruction'
failed after 28 iterations
Didn't expect signal from child: got `Illegal instruction'
failed after 12 iterations
What's happening here is that f() is invoked in a CLONE_VM cloned "thread",
without setting up TLS for that cloned thread (and therefore sharing TLS
with the parent thread).
The dynamic loader doesn't expect such sharing, and will crash if two
threads attempt to resolve some dynamic symbols at the same time.
The crash goes away when LD_BIND_NOW=1 is set in the environment,
as attached patch does.
Thanks,
--
nptl/ChangeLog:
2012-10-01 Paul Pluzhnikov <ppluzhnikov@google.com>
* nptl/Makefile (tst-getpid2-ENV): New variable.
diff --git a/nptl/Makefile b/nptl/Makefile
index b081b07..6f64b2c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -270,6 +270,9 @@ tests-nolibpthread = tst-unload
# of the page size since every architecture's page size is > 1k.
tst-oddstacklimit-ENV = ; ulimit -s 1023;
+# Avoid TLS race in dynamic loader
+tst-getpid2-ENV = LD_BIND_NOW=1
+
gen-as-const-headers = pthread-errnos.sym
LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
More information about the Libc-alpha
mailing list