Patchwork libgo patch committed: Include TLS size in stack size

mail settings
Submitter Ian Taylor
Date June 5, 2012, 1:12 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/163074/
State New
Headers show


Ian Taylor - June 5, 2012, 1:12 p.m.
Jakub Jelinek <> writes:

> On Mon, Jun 04, 2012 at 11:19:46PM -0700, Ian Lance Taylor wrote:
>> This patch to libgo includes the TLS size in the requested stack size of
>> a new thread, if possible.  This relies on the glibc-specific (and
>> undocumented) _dl_get_tls_static_info call.  This is particularly
>> necessary when using glibc, because glibc removes the static TLS size
>> from the requested stack space, and gives an error if there is not
>> enough space.  That means that a program that has a lot of TLS variables
>> will fail bizarrely, or worse may simply get a stack overflow
>> segmentation violation at runtime.  This patch is far from perfect, but
>> at least works around that problem for such programs.  Bootstrapped and
>> ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and
>> 4.7 branch.
> That is a very bad idea.  _dl_get_tls_static_info is @@GLIBC_PRIVATE symbol,
> therefore it must not be used by anything but glibc itself, may change or
> may be removed at any time.  Not using of GLIBC_PRIVATE symbols are even enforced
> by rpm, so if you build gcc as rpm, it won't install.  So especially
> committing that to 4.7 branch is fatal.
> Talk to for what should be done instead.

I knew it was nonportable, but I didn't realize that it would break rpm.
Disabled per richi's request, like so.  Patch committed to mainline and
4.7 branch.



diff -r 76c6ab4f8cdd libgo/runtime/proc.c
--- a/libgo/runtime/proc.c	Mon Jun 04 23:18:14 2012 -0700
+++ b/libgo/runtime/proc.c	Tue Jun 05 06:09:41 2012 -0700
@@ -1122,6 +1122,7 @@ 
 	stacksize = PTHREAD_STACK_MIN;
+#if 0
 		/* On GNU/Linux the static TLS size is taken out of
@@ -1142,6 +1143,7 @@ 
 		stacksize += tlssize;
 	if(pthread_attr_setstacksize(&attr, stacksize) != 0)