olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1372304-1.patch

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