|
|
00db10 |
This test requires a fix for max_align_t which is rolled into the
|
|
|
00db10 |
glibc-rh1418978-max_align_t.patch file.
|
|
|
00db10 |
|
|
|
00db10 |
commit b725132d2b0aeddf970b1ce3e5a24f8637a7b4c2
|
|
|
00db10 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
00db10 |
Date: Tue Jan 16 07:19:28 2018 +0100
|
|
|
00db10 |
|
|
|
00db10 |
nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions
|
|
|
00db10 |
|
|
|
00db10 |
commit 860b0240a5645edd6490161de3f8d1d1f2786025
|
|
|
00db10 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
00db10 |
Date: Mon Jan 15 15:30:00 2018 +0100
|
|
|
00db10 |
|
|
|
00db10 |
nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]
|
|
|
00db10 |
|
|
|
00db10 |
Index: glibc-2.17-c758a686/nptl/Makefile
|
|
|
00db10 |
===================================================================
|
|
|
00db10 |
--- glibc-2.17-c758a686.orig/nptl/Makefile
|
|
|
00db10 |
+++ glibc-2.17-c758a686/nptl/Makefile
|
|
|
00db10 |
@@ -198,6 +198,7 @@ CFLAGS-send.c = -fexceptions -fasynchron
|
|
|
00db10 |
|
|
|
00db10 |
CFLAGS-pt-system.c = -fexceptions
|
|
|
00db10 |
|
|
|
00db10 |
+CFLAGS-tst-minstack-throw.cc = -std=gnu++11
|
|
|
00db10 |
|
|
|
00db10 |
tests = tst-typesizes \
|
|
|
00db10 |
tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
|
|
|
00db10 |
@@ -268,7 +269,7 @@ tests = tst-typesizes \
|
|
|
00db10 |
tst-getpid1 tst-getpid2 tst-getpid3 \
|
|
|
00db10 |
tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99) \
|
|
|
00db10 |
tst-mutex-errorcheck \
|
|
|
00db10 |
- tst-minstack-cancel tst-minstack-exit
|
|
|
00db10 |
+ tst-minstack-cancel tst-minstack-exit tst-minstack-throw
|
|
|
00db10 |
xtests = tst-setuid1 tst-setuid1-static tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
|
|
|
00db10 |
test-srcs = tst-oddstacklimit
|
|
|
00db10 |
|
|
|
00db10 |
@@ -527,6 +528,7 @@ $(objpfx)tst-_res1: $(objpfx)tst-_res1mo
|
|
|
00db10 |
|
|
|
00db10 |
LDLIBS-tst-cancel24 = $(no-as-needed) -lstdc++
|
|
|
00db10 |
LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24)
|
|
|
00db10 |
+LDLIBS-tst-minstack-throw = -lstdc++
|
|
|
00db10 |
|
|
|
00db10 |
extra-B-pthread.so = -B$(common-objpfx)nptl/
|
|
|
00db10 |
$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
|
|
|
00db10 |
Index: glibc-2.17-c758a686/nptl/tst-minstack-throw.cc
|
|
|
00db10 |
===================================================================
|
|
|
00db10 |
--- /dev/null
|
|
|
00db10 |
+++ glibc-2.17-c758a686/nptl/tst-minstack-throw.cc
|
|
|
00db10 |
@@ -0,0 +1,87 @@
|
|
|
00db10 |
+/* Test that throwing C++ exceptions works with the minimum stack size.
|
|
|
00db10 |
+ Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
00db10 |
+ This file is part of the GNU C Library.
|
|
|
00db10 |
+
|
|
|
00db10 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
00db10 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
00db10 |
+ License as published by the Free Software Foundation; either
|
|
|
00db10 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
00db10 |
+
|
|
|
00db10 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
00db10 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
00db10 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
00db10 |
+ Lesser General Public License for more details.
|
|
|
00db10 |
+
|
|
|
00db10 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
00db10 |
+ License along with the GNU C Library; if not, see
|
|
|
00db10 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
00db10 |
+
|
|
|
00db10 |
+#include <stdexcept>
|
|
|
00db10 |
+
|
|
|
00db10 |
+#include <limits.h>
|
|
|
00db10 |
+#include <string.h>
|
|
|
00db10 |
+#include <support/check.h>
|
|
|
00db10 |
+#include <support/xthread.h>
|
|
|
00db10 |
+
|
|
|
00db10 |
+/* Throw a std::runtime_exception. */
|
|
|
00db10 |
+__attribute__ ((noinline, noclone, weak))
|
|
|
00db10 |
+void
|
|
|
00db10 |
+do_throw_exception ()
|
|
|
00db10 |
+{
|
|
|
00db10 |
+ throw std::runtime_error ("test exception");
|
|
|
00db10 |
+}
|
|
|
00db10 |
+
|
|
|
00db10 |
+/* Class with a destructor, to trigger unwind handling. */
|
|
|
00db10 |
+struct class_with_destructor
|
|
|
00db10 |
+{
|
|
|
00db10 |
+ class_with_destructor ();
|
|
|
00db10 |
+ ~class_with_destructor ();
|
|
|
00db10 |
+};
|
|
|
00db10 |
+
|
|
|
00db10 |
+__attribute__ ((noinline, noclone, weak))
|
|
|
00db10 |
+class_with_destructor::class_with_destructor ()
|
|
|
00db10 |
+{
|
|
|
00db10 |
+}
|
|
|
00db10 |
+
|
|
|
00db10 |
+__attribute__ ((noinline, noclone, weak))
|
|
|
00db10 |
+class_with_destructor::~class_with_destructor ()
|
|
|
00db10 |
+{
|
|
|
00db10 |
+}
|
|
|
00db10 |
+
|
|
|
00db10 |
+__attribute__ ((noinline, noclone, weak))
|
|
|
00db10 |
+void
|
|
|
00db10 |
+function_with_destructed_object ()
|
|
|
00db10 |
+{
|
|
|
00db10 |
+ class_with_destructor obj;
|
|
|
00db10 |
+ do_throw_exception ();
|
|
|
00db10 |
+}
|
|
|
00db10 |
+
|
|
|
00db10 |
+static void *
|
|
|
00db10 |
+threadfunc (void *closure)
|
|
|
00db10 |
+{
|
|
|
00db10 |
+ try
|
|
|
00db10 |
+ {
|
|
|
00db10 |
+ function_with_destructed_object ();
|
|
|
00db10 |
+ FAIL_EXIT1 ("no exception thrown");
|
|
|
00db10 |
+ }
|
|
|
00db10 |
+ catch (std::exception &e)
|
|
|
00db10 |
+ {
|
|
|
00db10 |
+ TEST_COMPARE (strcmp (e.what (), "test exception"), 0);
|
|
|
00db10 |
+ return reinterpret_cast<void *> (threadfunc);
|
|
|
00db10 |
+ }
|
|
|
00db10 |
+ FAIL_EXIT1 ("no exception caught");
|
|
|
00db10 |
+}
|
|
|
00db10 |
+
|
|
|
00db10 |
+static int
|
|
|
00db10 |
+do_test (void)
|
|
|
00db10 |
+{
|
|
|
00db10 |
+ pthread_attr_t attr;
|
|
|
00db10 |
+ xpthread_attr_init (&attr);
|
|
|
00db10 |
+ xpthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
|
|
|
00db10 |
+ pthread_t thr = xpthread_create (&attr, threadfunc, NULL);
|
|
|
00db10 |
+ TEST_VERIFY (xpthread_join (thr) == threadfunc);
|
|
|
00db10 |
+ xpthread_attr_destroy (&attr);
|
|
|
00db10 |
+ return 0;
|
|
|
00db10 |
+}
|
|
|
00db10 |
+
|
|
|
00db10 |
+#include <support/test-driver.c>
|