Blame SOURCES/glibc-rh1372304-1.patch

147e83
While the original upstream commit  adds several error-checked wrappers
147e83
around pthread functions in test-skeleton.c, a later upstream change
147e83
(c23de0aacb, containing the new support/ infrastructure for testing) removed
147e83
these wrappers and replaced them with an include declaration that provides
147e83
these functions (support/xthread.h). This backport does the same, because
147e83
the same change (new support/ infrastructure) is already included in RHEL as
147e83
well.
147e83
147e83
Also note: The correct sourceware bug number is 19946. The original upstream
147e83
commit message refers to an incorrect one.
147e83
147e83
commit 7e625f7e85b4e88f10dbde35a0641742af581806
147e83
Author: Florian Weimer <fweimer@redhat.com>
147e83
Date:   Fri Aug 26 19:27:16 2016 +0200
147e83
147e83
    nptl: Avoid expected SIGALRM in most tests [BZ #20432]
147e83
    
147e83
    Before this change, several tests did not detect early deadlocks
147e83
    because they used SIGALRM as the expected signal, and they ran
147e83
    for the full default TIMEOUT seconds.
147e83
    
147e83
    This commit adds a new delayed_exit function to the test skeleton,
147e83
    along with several error-checking wrappers to pthread functions.
147e83
    Additional error checking is introduced into several tests.
147e83
147e83
Index: b/nptl/tst-cond3.c
147e83
===================================================================
147e83
--- a/nptl/tst-cond3.c
147e83
+++ b/nptl/tst-cond3.c
147e83
@@ -22,6 +22,10 @@
147e83
 #include <string.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 /* Note that this test requires more than the standard.  It is
147e83
    required that there are no spurious wakeups if only more readers
147e83
@@ -50,7 +54,8 @@ tf (void *arg)
147e83
     }
147e83
 
147e83
   /* This call should never return.  */
147e83
-  pthread_cond_wait (&cond, &mut;;
147e83
+  xpthread_cond_wait (&cond, &mut;;
147e83
+  puts ("error: pthread_cond_wait in tf returned");
147e83
 
147e83
   /* We should never get here.  */
147e83
   exit (1);
147e83
@@ -96,17 +101,11 @@ do_test (void)
147e83
 	}
147e83
     }
147e83
 
147e83
-  /* Set an alarm for 1 second.  The wrapper will expect this.  */
147e83
-  alarm (1);
147e83
+  delayed_exit (1);
147e83
 
147e83
   /* This call should never return.  */
147e83
-  pthread_cond_wait (&cond, &mut;;
147e83
+  xpthread_cond_wait (&cond, &mut;;
147e83
 
147e83
-  puts ("cond_wait returned");
147e83
+  puts ("error: pthread_cond_wait in do_test returned");
147e83
   return 1;
147e83
 }
147e83
-
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-eintr1.c
147e83
===================================================================
147e83
--- a/nptl/tst-eintr1.c
147e83
+++ b/nptl/tst-eintr1.c
147e83
@@ -23,6 +23,11 @@
147e83
 #include <stdlib.h>
147e83
 #include <string.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
+
147e83
 #include "eintr.c"
147e83
 
147e83
 
147e83
@@ -92,13 +97,8 @@ do_test (void)
147e83
 	}
147e83
     }
147e83
 
147e83
+  delayed_exit (3);
147e83
+  /* This call must never return.  */
147e83
   (void) tf1 (NULL);
147e83
-  /* NOTREACHED */
147e83
-
147e83
-  return 0;
147e83
+  return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TIMEOUT 3
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-eintr2.c
147e83
===================================================================
147e83
--- a/nptl/tst-eintr2.c
147e83
+++ b/nptl/tst-eintr2.c
147e83
@@ -24,6 +24,11 @@
147e83
 #include <string.h>
147e83
 #include <sys/time.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
+
147e83
 #include "eintr.c"
147e83
 
147e83
 
147e83
@@ -103,6 +108,7 @@ do_test (void)
147e83
       exit (1);
147e83
     }
147e83
 
147e83
+  delayed_exit (3);
147e83
   /* This call must never return.  */
147e83
   e = pthread_mutex_lock (&m1;;
147e83
   printf ("main: mutex_lock returned: %s\n",
147e83
@@ -110,8 +116,3 @@ do_test (void)
147e83
 
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TIMEOUT 3
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-eintr3.c
147e83
===================================================================
147e83
--- a/nptl/tst-eintr3.c
147e83
+++ b/nptl/tst-eintr3.c
147e83
@@ -23,6 +23,11 @@
147e83
 #include <stdlib.h>
147e83
 #include <string.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
+
147e83
 #include "eintr.c"
147e83
 
147e83
 
147e83
@@ -56,16 +61,9 @@ do_test (void)
147e83
       exit (1);
147e83
     }
147e83
 
147e83
+  delayed_exit (1);
147e83
   /* This call must never return.  */
147e83
-  e = pthread_join (th, NULL);
147e83
-
147e83
-  if (e == EINTR)
147e83
-    puts ("pthread_join returned with EINTR");
147e83
-
147e83
-  return 0;
147e83
+  xpthread_join (th);
147e83
+  puts ("error: pthread_join returned");
147e83
+  return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TIMEOUT 1
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-eintr4.c
147e83
===================================================================
147e83
--- a/nptl/tst-eintr4.c
147e83
+++ b/nptl/tst-eintr4.c
147e83
@@ -23,6 +23,11 @@
147e83
 #include <stdlib.h>
147e83
 #include <string.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
+
147e83
 #include "eintr.c"
147e83
 
147e83
 
147e83
@@ -40,16 +45,9 @@ do_test (void)
147e83
       exit (1);
147e83
     }
147e83
 
147e83
+  delayed_exit (1);
147e83
   /* This call must never return.  */
147e83
-  int e = pthread_barrier_wait (&b);
147e83
-
147e83
-  if (e == EINTR)
147e83
-    puts ("pthread_join returned with EINTR");
147e83
-
147e83
-  return 0;
147e83
+  xpthread_barrier_wait (&b);
147e83
+  puts ("error: pthread_barrier_wait returned");
147e83
+  return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TIMEOUT 1
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-eintr5.c
147e83
===================================================================
147e83
--- a/nptl/tst-eintr5.c
147e83
+++ b/nptl/tst-eintr5.c
147e83
@@ -24,6 +24,11 @@
147e83
 #include <string.h>
147e83
 #include <sys/time.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
+
147e83
 #include "eintr.c"
147e83
 
147e83
 
147e83
@@ -66,15 +71,9 @@ do_test (void)
147e83
       exit (1);
147e83
     }
147e83
 
147e83
+  delayed_exit (3);
147e83
   /* This call must never return.  */
147e83
-  e = pthread_cond_wait (&c, &m);
147e83
-  printf ("main: cond_wait returned: %s\n",
147e83
-	  strerror_r (e, buf, sizeof (buf)));
147e83
-
147e83
-  return 0;
147e83
+  xpthread_cond_wait (&c, &m);
147e83
+  puts ("error: pthread_cond_wait returned");
147e83
+  return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TIMEOUT 3
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-exit2.c
147e83
===================================================================
147e83
--- a/nptl/tst-exit2.c
147e83
+++ b/nptl/tst-exit2.c
147e83
@@ -4,6 +4,10 @@
147e83
 #include <string.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 static void *
147e83
 tf (void *arg)
147e83
@@ -28,13 +32,11 @@ do_test (void)
147e83
       return 1;
147e83
     }
147e83
 
147e83
+  delayed_exit (1);
147e83
+
147e83
   /* Terminate only this thread.  */
147e83
   pthread_exit (NULL);
147e83
 
147e83
   /* NOTREACHED */
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-exit3.c
147e83
===================================================================
147e83
--- a/nptl/tst-exit3.c
147e83
+++ b/nptl/tst-exit3.c
147e83
@@ -5,6 +5,10 @@
147e83
 #include <string.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 static pthread_barrier_t b;
147e83
 
147e83
@@ -69,13 +73,11 @@ do_test (void)
147e83
       exit (1);
147e83
     }
147e83
 
147e83
+  delayed_exit (3);
147e83
+
147e83
   /* Terminate only this thread.  */
147e83
   pthread_exit (NULL);
147e83
 
147e83
   /* NOTREACHED */
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-mutex6.c
147e83
===================================================================
147e83
--- a/nptl/tst-mutex6.c
147e83
+++ b/nptl/tst-mutex6.c
147e83
@@ -22,6 +22,11 @@
147e83
 #include <unistd.h>
147e83
 #include <errno.h>
147e83
 
147e83
+#ifndef TEST_FUNCTION
147e83
+static int do_test (void);
147e83
+# define TEST_FUNCTION do_test ()
147e83
+#endif
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 #ifndef ATTR
147e83
 pthread_mutexattr_t *attr;
147e83
@@ -58,18 +63,10 @@ do_test (void)
147e83
       return 1;
147e83
     }
147e83
 
147e83
-  /* Set an alarm for 1 second.  The wrapper will expect this.  */
147e83
-  alarm (1);
147e83
-
147e83
+  delayed_exit (1);
147e83
   /* This call should never return.  */
147e83
-  pthread_mutex_lock (&m);
147e83
+  xpthread_mutex_lock (&m);
147e83
 
147e83
   puts ("2nd mutex_lock returned");
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#ifndef TEST_FUNCTION
147e83
-# define TEST_FUNCTION do_test ()
147e83
-#endif
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-rwlock5.c
147e83
===================================================================
147e83
--- a/nptl/tst-rwlock5.c
147e83
+++ b/nptl/tst-rwlock5.c
147e83
@@ -22,6 +22,10 @@
147e83
 #include <stdlib.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
147e83
 static pthread_rwlock_t r;
147e83
@@ -65,22 +69,16 @@ do_test (void)
147e83
       return 1;
147e83
     }
147e83
 
147e83
-  /* Set an alarm for 1 second.  The wrapper will expect this.  */
147e83
-  alarm (1);
147e83
-
147e83
   if (pthread_create (&th, NULL, tf, NULL) != 0)
147e83
     {
147e83
       puts ("create failed");
147e83
       return 1;
147e83
     }
147e83
 
147e83
+  delayed_exit (1);
147e83
   /* This call should never return.  */
147e83
-  pthread_mutex_lock (&m);
147e83
+  xpthread_mutex_lock (&m);
147e83
 
147e83
   puts ("2nd mutex_lock returned");
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-sem2.c
147e83
===================================================================
147e83
--- a/nptl/tst-sem2.c
147e83
+++ b/nptl/tst-sem2.c
147e83
@@ -17,11 +17,16 @@
147e83
    <http://www.gnu.org/licenses/>.  */
147e83
 
147e83
 #include <errno.h>
147e83
+#include <pthread.h>
147e83
 #include <semaphore.h>
147e83
 #include <signal.h>
147e83
 #include <stdio.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 static int
147e83
 do_test (void)
147e83
@@ -34,8 +39,7 @@ do_test (void)
147e83
       return 1;
147e83
     }
147e83
 
147e83
-  /* Set an alarm for 1 second.  The wrapper will expect this.  */
147e83
-  alarm (1);
147e83
+  delayed_exit (1);
147e83
 
147e83
   if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
147e83
     {
147e83
@@ -47,7 +51,3 @@ do_test (void)
147e83
   puts ("wait succeeded");
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-spin3.c
147e83
===================================================================
147e83
--- a/nptl/tst-spin3.c
147e83
+++ b/nptl/tst-spin3.c
147e83
@@ -21,6 +21,10 @@
147e83
 #include <stdio.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 static int
147e83
 do_test (void)
147e83
@@ -39,16 +43,11 @@ do_test (void)
147e83
       return 1;
147e83
     }
147e83
 
147e83
-  /* Set an alarm for 1 second.  The wrapper will expect this.  */
147e83
-  alarm (1);
147e83
+  delayed_exit (1);
147e83
 
147e83
   /* This call should never return.  */
147e83
-  pthread_spin_lock (&s);
147e83
+  xpthread_spin_lock (&s);
147e83
 
147e83
   puts ("2nd spin_lock returned");
147e83
   return 1;
147e83
 }
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/nptl/tst-stdio1.c
147e83
===================================================================
147e83
--- a/nptl/tst-stdio1.c
147e83
+++ b/nptl/tst-stdio1.c
147e83
@@ -21,6 +21,10 @@
147e83
 #include <stdio.h>
147e83
 #include <unistd.h>
147e83
 
147e83
+static int do_test (void);
147e83
+
147e83
+#define TEST_FUNCTION do_test ()
147e83
+#include "../test-skeleton.c"
147e83
 
147e83
 static void *tf (void *a)
147e83
 {
147e83
@@ -43,14 +47,10 @@ do_test (void)
147e83
       _exit (1);
147e83
     }
147e83
 
147e83
-  pthread_join (th, NULL);
147e83
+  delayed_exit (1);
147e83
+  xpthread_join (th);
147e83
 
147e83
   puts ("join returned");
147e83
 
147e83
-  return 0;
147e83
+  return 1;
147e83
 }
147e83
-
147e83
-
147e83
-#define EXPECTED_SIGNAL SIGALRM
147e83
-#define TEST_FUNCTION do_test ()
147e83
-#include "../test-skeleton.c"
147e83
Index: b/test-skeleton.c
147e83
===================================================================
147e83
--- a/test-skeleton.c
147e83
+++ b/test-skeleton.c
147e83
@@ -427,3 +427,9 @@ main (int argc, char *argv[])
147e83
   return 0;
147e83
 #endif
147e83
 }
147e83
+
147e83
+/* The following functionality is only available if <pthread.h> was
147e83
+   included before this file.  */
147e83
+#ifdef _PTHREAD_H
147e83
+# include <support/xthread.h>
147e83
+#endif	/* _PTHREAD_H */