Created attachment 6766 [details] tarball to reproduce bug If shared library declease a single TLS global variable of size 1 (one) byte, and this TLS variable is accessed by the binary linking against it the shared library doesnt get loaded because there is an error creating the static TLS block. The attached test case shows both the failed and expected behavior. Untar the files from the tar ball. To reproduce the bug please compile the shared library as follows: libfoo: gcc -g -Wall -Wextra -fPIC -pthread -shared -DBUG -o libfoo.so foo.c test: gcc -g -Wall -Wextra -DBUG -o test test.c -Wl,-rpath . -L . -lfoo $ ./test ./test: error while loading shared libraries: ./libfoo.so: cannot allocate memory in static TLS block To get the expected behavior recompile the tests as follows libfoo: gcc -g -Wall -Wextra -fPIC -pthread -shared -o libfoo.so foo.c test: gcc -g -Wall -Wextra -o test test.c -Wl,-rpath . -L . -lfoo $ ./test foo: 1 address of foo: 0x7f3d359c56fe The behavior is same if the library is compiled without -pthread. I have tested this bug in my system running Ubuntu precise using eglibc-2.15.
a45bd0d9682db986191b075e64bcacd038af5993 probably fixes that.
This appears to be fixed in current mainline (tested on mips64-linux-gnu). Moving milestone to 2.15.1.
Andreas, Your commit a45bd0d9682db986191b075e64bcacd038af5993 is only on the Fedora branch, yet I can't reproduce the problem with current sources. Was the bug fixed on trunk by a different patch?
I can reproduce this on a Centos 6.3 with glibc-2.12. I am trying to see if I can get access to a FC17 workstation.
(In reply to comment #3) > yet I can't reproduce the problem with current sources. I don't know what you tested, but the error is still present on master, and the commit still fixes it.
I tested this in a newer version of ubuntu running eglibc-2.16 and the error still exists. I will see if I can get access FC17 with glibc-2.15.
Andreas, Was your patch posted to libc-alpha@?
FC17 with glibc-2.15 doesnt have this issue.
Bharath, that's because Fedora has included the patch posted by Andreas.
Fixed in 2.17.
(In reply to Andreas Schwab from comment #10) > Fixed in 2.17. Just for reference, the fix was to adjust the internal constant not to be the same value as a small sized static TLS image. A workaround is always to increase the size of the TLS storage. commit 67cbf9a2a9e8953aa7ea875938d6646727c71aaa Author: Andreas Schwab <schwab@linux-m68k.org> Date: Fri Dec 7 14:55:19 2012 -0700 [BZ #14898] * include/link.h (FORCED_DYNAMIC_TLS_OFFSET) [NO_TLS_OFFSET == 0]: Change to -1.