@@ -76,8 +76,15 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
tst-secure-getenv tst-strtod-overflow tst-strtod-round \
tst-tininess tst-strtod-underflow tst-tls-atexit \
tst-setcontext3 tst-tls-atexit-nodelete \
- tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l
+ tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l \
+ tst-quick_exit
tests-static := tst-secure-getenv
+ifneq (,$(CXX))
+CFLAGS-tst-quick_exit.o = -std=c++11
+LDLIBS-tst-quick_exit = -lstdc++
+else
+tests-unsupported += tst-quick_exit
+endif
modules-names = tst-tls-atexit-lib
extra-test-objs += $(addsuffix .os, $(modules-names))
@@ -31,13 +31,14 @@ DEFINE_HOOK (__libc_atexit, (void))
void
attribute_hidden
__run_exit_handlers (int status, struct exit_function_list **listp,
- bool run_list_atexit)
+ bool run_list_atexit, bool run_dtors)
{
/* First, call the TLS destructors. */
#ifndef SHARED
if (&__call_tls_dtors != NULL)
#endif
- __call_tls_dtors ();
+ if (run_dtors)
+ __call_tls_dtors ();
/* We do it this way to handle recursive calls to exit () made by
the functions registered with `atexit' and `on_exit'. We call
@@ -101,6 +102,6 @@ __run_exit_handlers (int status, struct exit_function_list **listp,
void
exit (int status)
{
- __run_exit_handlers (status, &__exit_funcs, true);
+ __run_exit_handlers (status, &__exit_funcs, true, true);
}
libc_hidden_def (exit)
@@ -64,7 +64,7 @@ extern struct exit_function *__new_exitfn (struct exit_function_list **listp);
extern uint64_t __new_exitfn_called attribute_hidden;
extern void __run_exit_handlers (int status, struct exit_function_list **listp,
- bool run_list_atexit)
+ bool run_list_atexit, bool run_dtors)
attribute_hidden __attribute__ ((__noreturn__));
extern int __internal_atexit (void (*func) (void *), void *arg, void *d,
@@ -25,5 +25,5 @@
void
quick_exit (int status)
{
- __run_exit_handlers (status, &__quick_exit_funcs, false);
+ __run_exit_handlers (status, &__quick_exit_funcs, false, false);
}
new file mode 100644
@@ -0,0 +1,38 @@
+/* Bug 20198: Do not call object destructors at exit.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#include <cstdlib>
+
+struct A
+{
+ ~A() { abort(); }
+};
+
+thread_local A a;
+
+int
+main()
+{
+ (void)a;
+ /* The C++11 standard in 18.5.12 says:
+ "Objects shall not be destroyed as a result of calling
+ quick_exit."
+ If quick_exit calls the destructors the test aborts. */
+ std::quick_exit(0);
+ return 0;
+}
+