re PR libstdc++/23591 (exceptions in plugins in threads cause segmentation violation by leaving bad exit handler for the pthread)

2005-11-21  Benjamin Kosnik  <bkoz@redhat.com>
            Ulrich Drepper  <drepper@redhat.com>

	PR libstdc++/23591
	* scripts/create_testsuite_files: Support for "C" test files.
	* testsuite/lib/libstdc++.exp: Same.
	* testsuite/libstdc++-dg/normal.exp: Same.
	* testsuite/ext/mt_allocator/22309_thread.cc: Update names.
	* testsuite/19_diagnostics/23591_thread-1.c: New.
	* testsuite/testsuite_shared.cc: Add tests, rename existing functions.
	* libsupc++/eh_globals.cc: Make global thread local if possible.
	* configure.ac: Use GCC_CHECK_TLS.
	* acinclude.m4: Include tls.m4.
	* configure: Regenerate.
	* config.h.in: Same.


Co-Authored-By: Ulrich Drepper <drepper@redhat.com>

From-SVN: r107350
This commit is contained in:
Benjamin Kosnik 2005-11-22 06:54:08 +00:00 committed by Benjamin Kosnik
parent ebb109add8
commit cddfb1c7ac
20 changed files with 409 additions and 97 deletions

View File

@ -1,3 +1,19 @@
2005-11-21 Benjamin Kosnik <bkoz@redhat.com>
Ulrich Drepper <drepper@redhat.com>
PR libstdc++/23591
* scripts/create_testsuite_files: Support for "C" test files.
* testsuite/lib/libstdc++.exp: Same.
* testsuite/libstdc++-dg/normal.exp: Same.
* testsuite/ext/mt_allocator/22309_thread.cc: Update names.
* testsuite/19_diagnostics/23591_thread-1.c: New.
* testsuite/testsuite_shared.cc: Add tests, rename existing functions.
* libsupc++/eh_globals.cc: Make global thread local if possible.
* configure.ac: Use GCC_CHECK_TLS.
* acinclude.m4: Include tls.m4.
* configure: Regenerate.
* config.h.in: Same.
2005-11-21 Benjamin Kosnik <bkoz@redhat.com> 2005-11-21 Benjamin Kosnik <bkoz@redhat.com>
* libsupc++/del_op.cc: Include c++config.h first. * libsupc++/del_op.cc: Include c++config.h first.

View File

@ -45,11 +45,12 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/../config.guess \
$(top_srcdir)/scripts/testsuite_flags.in ChangeLog $(top_srcdir)/scripts/testsuite_flags.in ChangeLog
subdir = . subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \

View File

@ -1648,8 +1648,8 @@ EOF
rm -f conftest* rm -f conftest*
fi fi
# This is a tad weird, for hysterical raisins. We have to map enable/disable # This is a tad weird, for hysterical raisins. We have to map
# to two different models. # enable/disable to two different models.
case $enable_sjlj_exceptions in case $enable_sjlj_exceptions in
yes) yes)
AC_DEFINE(_GLIBCXX_SJLJ_EXCEPTIONS, 1, AC_DEFINE(_GLIBCXX_SJLJ_EXCEPTIONS, 1,
@ -1878,5 +1878,6 @@ AC_DEFUN([AC_LC_MESSAGES], [
]) ])
]) ])
# Macros from the top-level gcc directory.
m4_include([../config/tls.m4])
dnl vim:et:ts=2:sw=2

View File

@ -638,6 +638,7 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar]) AC_SUBST([am__untar])
]) # _AM_PROG_TAR ]) # _AM_PROG_TAR
m4_include([../config/enable.m4])
m4_include([../config/lead-dot.m4]) m4_include([../config/lead-dot.m4])
m4_include([../config/no-executables.m4]) m4_include([../config/no-executables.m4])
m4_include([../libtool.m4]) m4_include([../libtool.m4])

View File

@ -355,6 +355,9 @@
/* Define to 1 if you have the `tanl' function. */ /* Define to 1 if you have the `tanl' function. */
#undef HAVE_TANL #undef HAVE_TANL
/* Define to 1 if the target supports thread-local storage. */
#undef HAVE_TLS
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H

139
libstdc++-v3/configure vendored
View File

@ -887,6 +887,8 @@ Optional Features:
--enable-fully-dynamic-string --enable-fully-dynamic-string
do not put empty strings in per-process static do not put empty strings in per-process static
memory [default=no] memory [default=no]
_g_switchUse thread-local storage
[default=yes]
--enable-symvers=STYLE enables symbol versioning of the shared library --enable-symvers=STYLE enables symbol versioning of the shared library
[default=yes] [default=yes]
--enable-version-specific-runtime-libs --enable-version-specific-runtime-libs
@ -4456,7 +4458,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in case $host in
*-*-irix6*) *-*-irix6*)
# Find out which ABI we are using. # Find out which ABI we are using.
echo '#line 4459 "configure"' > conftest.$ac_ext echo '#line 4461 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5 (eval $ac_compile) 2>&5
ac_status=$? ac_status=$?
@ -5076,7 +5078,7 @@ fi;
# #
# Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style. # Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style.
cat > conftest.$ac_ext << EOF cat > conftest.$ac_ext << EOF
#line 5079 "configure" #line 5081 "configure"
struct S { ~S(); }; struct S { ~S(); };
void bar(); void bar();
void foo() void foo()
@ -5104,8 +5106,8 @@ EOF
rm -f conftest* rm -f conftest*
fi fi
# This is a tad weird, for hysterical raisins. We have to map enable/disable # This is a tad weird, for hysterical raisins. We have to map
# to two different models. # enable/disable to two different models.
case $enable_sjlj_exceptions in case $enable_sjlj_exceptions in
yes) yes)
@ -29929,6 +29931,135 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# For TLS support.
# Check whether --enable-tls or --disable-tls was given.
if test "${enable_tls+set}" = set; then
enableval="$enable_tls"
case "$enableval" in
yes|no) ;;
*) { { echo "$as_me:$LINENO: error: Argument to enable/disable tls must be yes or no" >&5
echo "$as_me: error: Argument to enable/disable tls must be yes or no" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
else
enable_tls=yes
fi;
echo "$as_me:$LINENO: checking whether the target supports thread-local storage" >&5
echo $ECHO_N "checking whether the target supports thread-local storage... $ECHO_C" >&6
if test "${have_tls+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
cat >conftest.$ac_ext <<_ACEOF
__thread int foo;
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
have_tls=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
have_tls=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
else
cat >conftest.$ac_ext <<_ACEOF
__thread int a; int b; int main() { return a = b; }
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
save_LDFLAGS="$LDFLAGS"
LDFLAGS="-static $LDFLAGS"
if test "$cross_compiling" = yes; then
{ { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
See \`config.log' for more details." >&5
echo "$as_me: error: cannot run test program while cross compiling
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
else
cat >conftest.$ac_ext <<_ACEOF
__thread int a; int b; int main() { return a = b; }
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
have_tls=yes
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
have_tls=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
LDFLAGS="$save_LDFLAGS"
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
have_tls=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $have_tls" >&5
echo "${ECHO_T}$have_tls" >&6
if test "$enable_tls $have_tls" = "yes yes"; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_TLS 1
_ACEOF
fi
if test "${ac_cv_header_locale_h+set}" = set; then if test "${ac_cv_header_locale_h+set}" = set; then
echo "$as_me:$LINENO: checking for locale.h" >&5 echo "$as_me:$LINENO: checking for locale.h" >&5

View File

@ -157,6 +157,9 @@ if $GLIBCXX_IS_NATIVE; then
# For LFS support. # For LFS support.
GLIBCXX_CHECK_LFS GLIBCXX_CHECK_LFS
# For TLS support.
GCC_CHECK_TLS
AC_LC_MESSAGES AC_LC_MESSAGES
AC_TRY_COMPILE( AC_TRY_COMPILE(

View File

@ -40,11 +40,12 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/fragment.am $(top_srcdir)/fragment.am
subdir = include subdir = include
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h

View File

@ -40,11 +40,12 @@ target_triplet = @target@
subdir = libmath subdir = libmath
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h

View File

@ -42,11 +42,12 @@ DIST_COMMON = $(glibcxxinstall_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/fragment.am $(srcdir)/Makefile.in $(top_srcdir)/fragment.am
subdir = libsupc++ subdir = libsupc++
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h

View File

@ -1,5 +1,5 @@
// -*- C++ -*- Manage the thread-local exception globals. // -*- C++ -*- Manage the thread-local exception globals.
// Copyright (C) 2001, 2004 Free Software Foundation, Inc. // Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc.
// //
// This file is part of GCC. // This file is part of GCC.
// //
@ -27,101 +27,127 @@
// invalidate any other reasons why the executable file might be covered by // invalidate any other reasons why the executable file might be covered by
// the GNU General Public License. // the GNU General Public License.
#include <bits/c++config.h>
#include <exception> #include <exception>
#include <cstdlib> #include <cstdlib>
#include "cxxabi.h"
#include "unwind-cxx.h" #include "unwind-cxx.h"
#include "bits/c++config.h"
#include "bits/gthr.h" #include "bits/gthr.h"
using namespace __cxxabiv1; using namespace __cxxabiv1;
#if _GLIBCXX_HAVE_TLS
namespace __gnu_internal
{
using namespace abi;
using namespace std;
__cxa_eh_globals*
get_global() throw()
{
static __thread __cxa_eh_globals global;
return &global;
}
}
extern "C" __cxa_eh_globals*
__cxxabiv1::__cxa_get_globals_fast() throw()
{ return __gnu_internal::get_global(); }
extern "C" __cxa_eh_globals*
__cxxabiv1::__cxa_get_globals() throw()
{ return __gnu_internal::get_global(); }
#else
// Single-threaded fallback buffer. // Single-threaded fallback buffer.
static __cxa_eh_globals globals_static; static __cxa_eh_globals eh_globals;
#if __GTHREADS #if __GTHREADS
static __gthread_key_t globals_key;
static int use_thread_key = -1;
static void static void
get_globals_dtor (void *ptr) eh_globals_dtor(void* ptr)
{ {
if (ptr) if (ptr)
{ {
__cxa_exception *exn, *next; __cxa_eh_globals* g = reinterpret_cast<__cxa_eh_globals*>(ptr);
exn = ((__cxa_eh_globals *) ptr)->caughtExceptions; __cxa_exception* exn = g->caughtExceptions;
__cxa_exception* next;
while (exn) while (exn)
{ {
next = exn->nextException; next = exn->nextException;
_Unwind_DeleteException (&exn->unwindHeader); _Unwind_DeleteException(&exn->unwindHeader);
exn = next; exn = next;
} }
std::free (ptr); std::free(ptr);
} }
} }
static void struct __eh_globals_init
get_globals_init ()
{ {
use_thread_key = __gthread_key_t _M_key;
(__gthread_key_create (&globals_key, get_globals_dtor) == 0); bool _M_init;
}
static void __eh_globals_init() : _M_init(false)
get_globals_init_once () {
{ if (__gthread_active_p())
static __gthread_once_t once = __GTHREAD_ONCE_INIT; _M_init = __gthread_key_create(&_M_key, eh_globals_dtor) == 0;
if (__gthread_once (&once, get_globals_init) != 0 }
|| use_thread_key < 0)
use_thread_key = 0;
}
#endif
extern "C" __cxa_eh_globals * ~__eh_globals_init()
__cxxabiv1::__cxa_get_globals_fast () throw() {
if (_M_init)
__gthread_key_delete(_M_key);
}
};
static __eh_globals_init init;
extern "C" __cxa_eh_globals*
__cxxabiv1::__cxa_get_globals_fast() throw()
{ {
#if __GTHREADS __cxa_eh_globals* g;
if (use_thread_key) if (init._M_init)
return (__cxa_eh_globals *) __gthread_getspecific (globals_key); g = static_cast<__cxa_eh_globals*>(__gthread_getspecific(init._M_key));
else else
return &globals_static; g = &eh_globals;
#else return g;
return &globals_static;
#endif
} }
extern "C" __cxa_eh_globals * extern "C" __cxa_eh_globals*
__cxxabiv1::__cxa_get_globals () throw() __cxxabiv1::__cxa_get_globals() throw()
{ {
#if __GTHREADS __cxa_eh_globals* g;
__cxa_eh_globals *g; if (init._M_init)
if (use_thread_key == 0)
return &globals_static;
if (use_thread_key < 0)
{ {
get_globals_init_once (); g = static_cast<__cxa_eh_globals*>(__gthread_getspecific(init._M_key));
if (!g)
// Make sure use_thread_key got initialized.
if (use_thread_key == 0)
return &globals_static;
}
g = (__cxa_eh_globals *) __gthread_getspecific (globals_key);
if (! g)
{ {
if ((g = (__cxa_eh_globals *) void* v = std::malloc(sizeof(__cxa_eh_globals));
std::malloc (sizeof (__cxa_eh_globals))) == 0 if (v == 0 || __gthread_setspecific(init._M_key, v) != 0)
|| __gthread_setspecific (globals_key, (void *) g) != 0) std::terminate();
std::terminate (); g = static_cast<__cxa_eh_globals*>(v);
g->caughtExceptions = 0; g->caughtExceptions = 0;
g->uncaughtExceptions = 0; g->uncaughtExceptions = 0;
} }
}
else
g = &eh_globals;
return g; return g;
#else
return &globals_static;
#endif
} }
#else
extern "C" __cxa_eh_globals*
__cxxabiv1::__cxa_get_globals_fast() throw()
{ return &eh_globals; }
extern "C" __cxa_eh_globals*
__cxxabiv1::__cxa_get_globals() throw()
{ return &eh_globals; }
#endif
#endif

View File

@ -40,11 +40,12 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/fragment.am $(top_srcdir)/fragment.am
subdir = po subdir = po
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h

View File

@ -35,7 +35,9 @@ dlist=`echo [0-9][0-9]*`
for d in [a-z]*; do for d in [a-z]*; do
test -d $d && dlist="$dlist $d" test -d $d && dlist="$dlist $d"
done done
find $dlist "(" -type f -o -type l ")" -name "*.cc" -print | sort > $tmp.1 find $dlist "(" -type f -o -type l ")" -name "*.cc" -print > $tmp.01
find $dlist "(" -type f -o -type l ")" -name "*.c" -print > $tmp.02
cat $tmp.01 $tmp.02 | sort > $tmp.1
if test ! -s "$tmp.1"; then if test ! -s "$tmp.1"; then
exit 1 exit 1
fi fi

View File

@ -40,11 +40,12 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/fragment.am $(top_srcdir)/fragment.am
subdir = src subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h

View File

@ -0,0 +1,63 @@
// { dg-require-sharedlib "" }
// { dg-options "-g -O2 -pthread -ldl -x c" { target *-*-linux* } }
// Copyright (C) 2005 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <pthread.h>
#include <dlfcn.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
// NB: This must be compiled and linked as a "C" executable.
static void* run(void* arg)
{
typedef void (*function_type) (void);
void* lib;
void (*cb)();
lib = dlopen("./testsuite_shared.so", RTLD_NOW);
if (lib == NULL)
{
printf("dlopen failed: %s\n", strerror(errno));
return NULL;
}
cb = (function_type) dlsym(lib, "try_throw_exception");
if (cb == NULL)
{
printf("dlsym failed: %s\n", strerror(errno));
return NULL;
}
cb();
dlclose(lib);
return NULL;
}
// libstdc++/23591
int main(void)
{
pthread_t pt;
if (pthread_create(&pt, NULL, &run, NULL) != 0)
return 1;
if (pthread_join(pt, NULL) != 0)
return 1;
return 0;
}

View File

@ -40,11 +40,12 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/fragment.am $(top_srcdir)/fragment.am
subdir = testsuite subdir = testsuite
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../config/no-executables.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \
$(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h

View File

@ -50,7 +50,7 @@ check_dlsym(void*& h)
typedef void (*function_type) (void); typedef void (*function_type) (void);
function_type fn; function_type fn;
fn = reinterpret_cast<function_type>(dlsym(h, "foo")); fn = reinterpret_cast<function_type>(dlsym(h, "try_allocation"));
try try
{ {

View File

@ -271,9 +271,27 @@ proc libstdc++-dg-test { prog do_what extra_tool_flags } {
return "" return ""
} }
} }
set options "" set options ""
if { $extra_tool_flags != "" } { if { $extra_tool_flags != "" } {
verbose -log "extra_tool_flags are:"
verbose -log $extra_tool_flags
if { [string first "-x c" $extra_tool_flags ] != -1 } {
# Short-circut a bunch of complicated goo here for the
# special case of compiling a test file as a "C" file, not
# as C++: just use target_compile, instead of the usual
# gimmicks.
verbose -log "compiling and executing as C, not C++"
set compile_type "executable"
set output_file "./[file rootname [file tail $prog]].exe"
remote_file build delete $output_file;
lappend options "additional_flags=$extra_tool_flags" lappend options "additional_flags=$extra_tool_flags"
set comp_output [target_compile "$prog" "$output_file" "$compile_type" $options];
set comp_output [ prune_g++_output $comp_output ];
return [list $comp_output $output_file]
} else {
lappend options "additional_flags=$extra_tool_flags"
}
} }
# There is a libstdc++_compile made for us by default (via the tool- # There is a libstdc++_compile made for us by default (via the tool-
@ -608,8 +626,7 @@ proc check_v3_target_debug_mode { } {
set et_debug_mode 0 set et_debug_mode 0
# Set up, compile, and execute a C++ test program that depends # Set up, compile, and execute a C++ test program that depends
# on correct ordering of static object destructors. This is # on debug mode working.
# indicative of the presence and use of __cxa_atexit.
set src debug_mode[pid].cc set src debug_mode[pid].cc
set exe debug_mode[pid].exe set exe debug_mode[pid].exe

View File

@ -1,4 +1,4 @@
# Primary test file for libstdc++. # Functional and regression tests in C++ for libstdc++.
# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
# #
@ -61,6 +61,11 @@ if {[info exists tests_file] && [file exists $tests_file]} {
# Find all the tests. # Find all the tests.
foreach s $subdirs { foreach s $subdirs {
set subdir_tests [find $s *.cc] set subdir_tests [find $s *.cc]
set subdir_tests_c [find $s *.c]
foreach e $subdir_tests_c {
lappend subdir_tests $e
}
# Filter out tests that should not be run. # Filter out tests that should not be run.
foreach t $subdir_tests { foreach t $subdir_tests {
# The DejaGNU "find" procedure sometimes returns a list # The DejaGNU "find" procedure sometimes returns a list

View File

@ -17,11 +17,14 @@
// USA. // USA.
#include <string> #include <string>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <ext/mt_allocator.h> #include <ext/mt_allocator.h>
// libstdc++/22309 // libstdc++/22309
extern "C" void extern "C" void
foo() try_allocation()
{ {
typedef char value_t; typedef char value_t;
@ -34,3 +37,37 @@ foo()
string_t s; string_t s;
s += "west beach, indiana dunes"; s += "west beach, indiana dunes";
} }
// libstdc++/23591
extern "C" void
try_throw_exception()
{
try
{
throw std::bad_exception();
}
catch (const std::exception& e)
{ }
}
extern "C" void
try_function_random_fail()
{
long seed = lrand48();
if (seed < 2000)
seed = 2000;
{
std::ostringstream s;
s << "random_throw, seed: " << seed << std::endl;
std::cout << s.str();
}
while (--seed > 0)
{
try_throw_exception();
}
// Randomly throw. See if other threads cleanup.
throw std::bad_exception();
}