|
|
fa3bfd |
This test requires a fix for max_align_t which is rolled into the
|
|
|
fa3bfd |
glibc-rh1418978-max_align_t.patch file.
|
|
|
fa3bfd |
|
|
|
fa3bfd |
commit b725132d2b0aeddf970b1ce3e5a24f8637a7b4c2
|
|
|
fa3bfd |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
fa3bfd |
Date: Tue Jan 16 07:19:28 2018 +0100
|
|
|
fa3bfd |
|
|
|
fa3bfd |
nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions
|
|
|
fa3bfd |
|
|
|
fa3bfd |
commit 860b0240a5645edd6490161de3f8d1d1f2786025
|
|
|
fa3bfd |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
fa3bfd |
Date: Mon Jan 15 15:30:00 2018 +0100
|
|
|
fa3bfd |
|
|
|
fa3bfd |
nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]
|
|
|
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 |
@@ -198,6 +198,7 @@ CFLAGS-send.c = -fexceptions -fasynchron
|
|
|
fa3bfd |
|
|
|
fa3bfd |
CFLAGS-pt-system.c = -fexceptions
|
|
|
fa3bfd |
|
|
|
fa3bfd |
+CFLAGS-tst-minstack-throw.cc = -std=gnu++11
|
|
|
fa3bfd |
|
|
|
fa3bfd |
tests = tst-typesizes \
|
|
|
fa3bfd |
tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
|
|
|
fa3bfd |
@@ -268,7 +269,7 @@ tests = tst-typesizes \
|
|
|
fa3bfd |
tst-getpid1 tst-getpid2 tst-getpid3 \
|
|
|
fa3bfd |
tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99) \
|
|
|
fa3bfd |
tst-mutex-errorcheck \
|
|
|
fa3bfd |
- tst-minstack-cancel tst-minstack-exit
|
|
|
fa3bfd |
+ tst-minstack-cancel tst-minstack-exit tst-minstack-throw
|
|
|
fa3bfd |
xtests = tst-setuid1 tst-setuid1-static tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
|
|
|
fa3bfd |
test-srcs = tst-oddstacklimit
|
|
|
fa3bfd |
|
|
|
fa3bfd |
@@ -527,6 +528,7 @@ $(objpfx)tst-_res1: $(objpfx)tst-_res1mo
|
|
|
fa3bfd |
|
|
|
fa3bfd |
LDLIBS-tst-cancel24 = $(no-as-needed) -lstdc++
|
|
|
fa3bfd |
LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24)
|
|
|
fa3bfd |
+LDLIBS-tst-minstack-throw = -lstdc++
|
|
|
fa3bfd |
|
|
|
fa3bfd |
extra-B-pthread.so = -B$(common-objpfx)nptl/
|
|
|
fa3bfd |
$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
|
|
|
fa3bfd |
Index: glibc-2.17-c758a686/nptl/tst-minstack-throw.cc
|
|
|
fa3bfd |
===================================================================
|
|
|
fa3bfd |
--- /dev/null
|
|
|
fa3bfd |
+++ glibc-2.17-c758a686/nptl/tst-minstack-throw.cc
|
|
|
fa3bfd |
@@ -0,0 +1,87 @@
|
|
|
fa3bfd |
+/* Test that throwing C++ exceptions 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 |
+#include <stdexcept>
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+#include <limits.h>
|
|
|
fa3bfd |
+#include <string.h>
|
|
|
fa3bfd |
+#include <support/check.h>
|
|
|
fa3bfd |
+#include <support/xthread.h>
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+/* Throw a std::runtime_exception. */
|
|
|
fa3bfd |
+__attribute__ ((noinline, noclone, weak))
|
|
|
fa3bfd |
+void
|
|
|
fa3bfd |
+do_throw_exception ()
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ throw std::runtime_error ("test exception");
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+/* Class with a destructor, to trigger unwind handling. */
|
|
|
fa3bfd |
+struct class_with_destructor
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ class_with_destructor ();
|
|
|
fa3bfd |
+ ~class_with_destructor ();
|
|
|
fa3bfd |
+};
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+__attribute__ ((noinline, noclone, weak))
|
|
|
fa3bfd |
+class_with_destructor::class_with_destructor ()
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+__attribute__ ((noinline, noclone, weak))
|
|
|
fa3bfd |
+class_with_destructor::~class_with_destructor ()
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+__attribute__ ((noinline, noclone, weak))
|
|
|
fa3bfd |
+void
|
|
|
fa3bfd |
+function_with_destructed_object ()
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ class_with_destructor obj;
|
|
|
fa3bfd |
+ do_throw_exception ();
|
|
|
fa3bfd |
+}
|
|
|
fa3bfd |
+
|
|
|
fa3bfd |
+static void *
|
|
|
fa3bfd |
+threadfunc (void *closure)
|
|
|
fa3bfd |
+{
|
|
|
fa3bfd |
+ try
|
|
|
fa3bfd |
+ {
|
|
|
fa3bfd |
+ function_with_destructed_object ();
|
|
|
fa3bfd |
+ FAIL_EXIT1 ("no exception thrown");
|
|
|
fa3bfd |
+ }
|
|
|
fa3bfd |
+ catch (std::exception &e)
|
|
|
fa3bfd |
+ {
|
|
|
fa3bfd |
+ TEST_COMPARE (strcmp (e.what (), "test exception"), 0);
|
|
|
fa3bfd |
+ return reinterpret_cast<void *> (threadfunc);
|
|
|
fa3bfd |
+ }
|
|
|
fa3bfd |
+ FAIL_EXIT1 ("no exception caught");
|
|
|
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>
|