[BZ#17090/17620/17621] : fix DTV race, assert, and DTV_SURPLUS Static TLS limit

Message ID 20150304110430.GE26435@bubble.grove.modra.org
State Not applicable
Headers

Commit Message

Alan Modra March 4, 2015, 11:04 a.m. UTC
  On Wed, Mar 04, 2015 at 03:35:29PM +1030, Alan Modra wrote:
> As does nptl/tst-stack4 on x86_64 if tst-stack4mod.so is built with
> -mtls-dialect=gnu2.

This on top of your patch gets me past the segfault in free().


I now hit another segfault, tst-stack4mod.c:function somehow has
var == NULL.
  

Comments

Alexandre Oliva March 5, 2015, 5:14 p.m. UTC | #1
On Mar  4, 2015, Alan Modra <amodra@gmail.com> wrote:

> On Wed, Mar 04, 2015 at 03:35:29PM +1030, Alan Modra wrote:
>> As does nptl/tst-stack4 on x86_64 if tst-stack4mod.so is built with
>> -mtls-dialect=gnu2.

> This on top of your patch gets me past the segfault in free().

Thanks.  I've put an equivalent fix into my local tree, for an updated
version of the patch.

> I now hit another segfault, tst-stack4mod.c:function somehow has
> var == NULL.

I'm looking into it.  Thanks,
  
Szabolcs Nagy March 5, 2015, 5:25 p.m. UTC | #2
* Alexandre Oliva <aoliva@redhat.com> [2015-03-05 14:14:06 -0300]:
> On Mar  4, 2015, Alan Modra <amodra@gmail.com> wrote:
> 
> > On Wed, Mar 04, 2015 at 03:35:29PM +1030, Alan Modra wrote:
> >> As does nptl/tst-stack4 on x86_64 if tst-stack4mod.so is built with
> >> -mtls-dialect=gnu2.
> 
> > This on top of your patch gets me past the segfault in free().
> 
> Thanks.  I've put an equivalent fix into my local tree, for an updated
> version of the patch.
> 

note that nptl/tst-stack4 may fail on x86_64 without tlsdesc
you just need to amplify the probability a bit:

https://sourceware.org/bugzilla/show_bug.cgi?id=17918
  

Patch

diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 311cc6d..44e2a2b 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -674,6 +674,9 @@  _dl_update_slotinfo (unsigned long int req_modid)
 	      struct link_map *map = listp->slotinfo[cnt].map;
 	      if (map == NULL)
 		{
+		  if (dtv[-1].counter < total + cnt)
+		    continue;
+
 		  /* If this modid was used at some point the memory
 		     might still be allocated.  */
 		  if (! dtv[total + cnt].pointer.is_static