446cf2
commit d330f31af68f96dde82840d1e9343b479a8c179e
446cf2
Author: Carlos O'Donell <carlos@redhat.com>
446cf2
Date:   Thu Aug 30 11:01:33 2018 -0400
446cf2
446cf2
    Fix test failure with -DNDEBUG.
446cf2
    
446cf2
    The elf/tst-dlopen-aout.c test uses asserts to verify properties of the
446cf2
    test execution.  Instead of using assert it should use xpthread_create
446cf2
    and xpthread_join to catch errors starting the threads and fail the
446cf2
    test.  This shows up in Fedora 28 when building for i686-pc-linux-gnu
446cf2
    and using gcc 8.1.1.
446cf2
    
446cf2
    Tested on i686, and fixes a check failure with -DNDEBUG.
446cf2
    
446cf2
    Signed-off-by: Carlos O'Donell <carlos@redhat.com>
446cf2
446cf2
diff --git a/elf/tst-dlopen-aout.c b/elf/tst-dlopen-aout.c
446cf2
index 9038e2096add8798..b0264515cfe62276 100644
446cf2
--- a/elf/tst-dlopen-aout.c
446cf2
+++ b/elf/tst-dlopen-aout.c
446cf2
@@ -27,6 +27,7 @@
446cf2
 #include <dlfcn.h>
446cf2
 #include <stdio.h>
446cf2
 #include <pthread.h>
446cf2
+#include <support/xthread.h>
446cf2
 
446cf2
 __thread int x;
446cf2
 
446cf2
@@ -45,7 +46,6 @@ do_test (int argc, char *argv[])
446cf2
     {
446cf2
       pthread_t thr;
446cf2
       void *p;
446cf2
-      int rc;
446cf2
 
446cf2
       p = dlopen (argv[0], RTLD_LAZY);
446cf2
       if (p != NULL)
446cf2
@@ -53,11 +53,11 @@ do_test (int argc, char *argv[])
446cf2
           fprintf (stderr, "dlopen unexpectedly succeeded\n");
446cf2
           return 1;
446cf2
         }
446cf2
-      rc = pthread_create (&thr, NULL, fn, NULL);
446cf2
-      assert (rc == 0);
446cf2
-
446cf2
-      rc = pthread_join (thr, NULL);
446cf2
-      assert (rc == 0);
446cf2
+      /* We create threads to force TLS allocation, which triggers
446cf2
+	 the original bug i.e. running out of surplus slotinfo entries
446cf2
+	 for TLS.  */
446cf2
+      thr = xpthread_create (NULL, fn, NULL);
446cf2
+      xpthread_join (thr);
446cf2
     }
446cf2
 
446cf2
   return 0;