|
|
fa3bfd |
commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1
|
|
|
fa3bfd |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
fa3bfd |
Date: Thu Jan 11 13:13:14 2018 +0100
|
|
|
fa3bfd |
|
|
|
fa3bfd |
nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]
|
|
|
fa3bfd |
|
|
|
fa3bfd |
I verified that without the guard accounting change in commit
|
|
|
fa3bfd |
630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
|
|
|
fa3bfd |
accounting) and RTLD_NOW for libgcc_s introduced by commit
|
|
|
fa3bfd |
f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
|
|
|
fa3bfd |
RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
|
|
|
fa3bfd |
an AVX-512F machine. tst-minstack-exit still passes, and either of
|
|
|
fa3bfd |
the mentioned commit by itself frees sufficient stack space to make
|
|
|
fa3bfd |
tst-minstack-cancel pass, too.
|
|
|
fa3bfd |
|
|
|
fa3bfd |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
fa3bfd |
|
|
|
fa3bfd |
Index: glibc-2.17-c758a686/nptl/Makefile
|
|
|
fa3bfd |
===================================================================
|
|
|
fa3bfd |
--- glibc-2.17-c758a686.orig/nptl/Makefile
|
|
|
fa3bfd |
+++ glibc-2.17-c758a686/nptl/Makefile
|
|
|
fa3bfd |
@@ -267,7 +267,8 @@ tests = tst-typesizes \
|
|
|
fa3bfd |
tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
|
|
|
fa3bfd |
tst-getpid1 tst-getpid2 tst-getpid3 \
|
|
|
fa3bfd |
tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99) \
|
|
|
fa3bfd |
- tst-mutex-errorcheck
|
|
|
fa3bfd |
+ tst-mutex-errorcheck \
|
|
|
fa3bfd |
+ tst-minstack-cancel tst-minstack-exit
|
|
|
fa3bfd |
xtests = tst-setuid1 tst-setuid1-static tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
|
|
|
fa3bfd |
test-srcs = tst-oddstacklimit
|
|
|
fa3bfd |
|
|
|
fa3bfd |
Index: glibc-2.17-c758a686/nptl/tst-minstack-cancel.c
|
|
|
fa3bfd |
===================================================================
|
|
|
fa3bfd |
--- /dev/null
|
|
|
fa3bfd |
+++ glibc-2.17-c758a686/nptl/tst-minstack-cancel.c
|
|
|
fa3bfd |
@@ -0,0 +1,48 @@
|
|
|
fa3bfd |
+/* Test cancellation with a minimal stack size.
|
|
|
fa3bfd |
+ Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
fa3bfd |
+ This file is part of the GNU C Library.
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
fa3bfd |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
fa3bfd |
+ License as published by the Free Software Foundation; either
|
|
|
fa3bfd |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
fa3bfd |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
fa3bfd |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
fa3bfd |
+ Lesser General Public License for more details.
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
fa3bfd |
+ License along with the GNU C Library; if not, see
|
|
|
fa3bfd |
+ <http://www.gnu.org/licenses/>. */
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+/* Note: This test is similar to tst-minstack-exit, but is separate to
|
|
|
fa3bfd |
+ avoid spurious test passes due to warm-up effects. */
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+#include <limits.h>
|
|
|
fa3bfd |
+#include <unistd.h>
|
|
|
fa3bfd |
+#include <support/check.h>
|
|
|
fa3bfd |
+#include <support/xthread.h>
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+static void *
|
|
|
fa3bfd |
+threadfunc (void *closure)
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ while (1)
|
|
|
fa3bfd |
+ pause ();
|
|
|
fa3bfd |
+ return NULL;
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+static int
|
|
|
fa3bfd |
+do_test (void)
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ pthread_attr_t attr;
|
|
|
fa3bfd |
+ xpthread_attr_init (&attr);
|
|
|
fa3bfd |
+ xpthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
|
|
|
fa3bfd |
+ pthread_t thr = xpthread_create (&attr, threadfunc, NULL);
|
|
|
fa3bfd |
+ xpthread_cancel (thr);
|
|
|
fa3bfd |
+ TEST_VERIFY (xpthread_join (thr) == PTHREAD_CANCELED);
|
|
|
fa3bfd |
+ xpthread_attr_destroy (&attr);
|
|
|
fa3bfd |
+ return 0;
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+#include <support/test-driver.c>
|
|
|
fa3bfd |
Index: glibc-2.17-c758a686/nptl/tst-minstack-exit.c
|
|
|
fa3bfd |
===================================================================
|
|
|
fa3bfd |
--- /dev/null
|
|
|
fa3bfd |
+++ glibc-2.17-c758a686/nptl/tst-minstack-exit.c
|
|
|
fa3bfd |
@@ -0,0 +1,46 @@
|
|
|
fa3bfd |
+/* Test that pthread_exit works with the minimum stack size.
|
|
|
fa3bfd |
+ Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
fa3bfd |
+ This file is part of the GNU C Library.
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
fa3bfd |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
fa3bfd |
+ License as published by the Free Software Foundation; either
|
|
|
fa3bfd |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
fa3bfd |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
fa3bfd |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
fa3bfd |
+ Lesser General Public License for more details.
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
fa3bfd |
+ License along with the GNU C Library; if not, see
|
|
|
fa3bfd |
+ <http://www.gnu.org/licenses/>. */
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+/* Note: This test is similar to tst-minstack-cancel, but is separate
|
|
|
fa3bfd |
+ to avoid spurious test passes due to warm-up effects. */
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+#include <limits.h>
|
|
|
fa3bfd |
+#include <unistd.h>
|
|
|
fa3bfd |
+#include <support/check.h>
|
|
|
fa3bfd |
+#include <support/xthread.h>
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+static void *
|
|
|
fa3bfd |
+threadfunc (void *closure)
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ pthread_exit (threadfunc);
|
|
|
fa3bfd |
+ return NULL;
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+static int
|
|
|
fa3bfd |
+do_test (void)
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ pthread_attr_t attr;
|
|
|
fa3bfd |
+ xpthread_attr_init (&attr);
|
|
|
fa3bfd |
+ xpthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
|
|
|
fa3bfd |
+ pthread_t thr = xpthread_create (&attr, threadfunc, NULL);
|
|
|
fa3bfd |
+ TEST_VERIFY (xpthread_join (thr) == threadfunc);
|
|
|
fa3bfd |
+ xpthread_attr_destroy (&attr);
|
|
|
fa3bfd |
+ return 0;
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+#include <support/test-driver.c>
|