From: Mark Mitchell Date: Sat, 21 Feb 2004 20:59:26 +0000 (+0000) Subject: * libsupc++/vterminate.cc X-Git-Tag: releases/gcc-4.0.0~9939 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afc3bb58d5cb56d62b6b6a5c7bafcc27357e35db;p=thirdparty%2Fgcc.git * libsupc++/vterminate.cc (__gnu_cxx::__verbose_terminate_handler): Guard against recursive calls to terminate. * src/demangle.cc (__cxa_demangle): Wrap in try-catch block. From-SVN: r78235 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a98b01df820f..e560c6c16bca 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2004-02-21 Mark Mitchell + + * libsupc++/vterminate.cc + (__gnu_cxx::__verbose_terminate_handler): Guard against recursive + calls to terminate. + * src/demangle.cc (__cxa_demangle): Wrap in try-catch block. + + * testsuite/testsuite_hooks.cc (__gnu_test::set_memory_limits): Do + not set RLIMIT_AS on HP-UX. + 2004-02-21 Mark Mitchell * testsuite/testsuite_hooks.cc (__gnu_test::set_memory_limits): Do diff --git a/libstdc++-v3/libsupc++/vterminate.cc b/libstdc++-v3/libsupc++/vterminate.cc index 38f6f617868a..0ec9f2ccfe4c 100644 --- a/libstdc++-v3/libsupc++/vterminate.cc +++ b/libstdc++-v3/libsupc++/vterminate.cc @@ -51,6 +51,16 @@ namespace __gnu_cxx stderr. */ void __verbose_terminate_handler() { + static bool terminating; + + if (terminating) + { + writestr ("terminate called recursively\n"); + abort (); + } + + terminating = true; + // Make sure there was an exception; terminate is also called for an // attempt to rethrow when there is no suitable exception. type_info *t = __cxa_current_exception_type(); diff --git a/libstdc++-v3/src/demangle.cc b/libstdc++-v3/src/demangle.cc index 1221f4cb40b6..779076d3554b 100644 --- a/libstdc++-v3/src/demangle.cc +++ b/libstdc++-v3/src/demangle.cc @@ -106,63 +106,67 @@ namespace __cxxabiv1 __cxa_demangle(char const* mangled_name, char* buf, std::size_t* n, int* status) { - using namespace __gnu_cxx; - typedef demangler::session > session_type; + try { + using namespace __gnu_cxx; + typedef demangler::session > session_type; - if (!mangled_name || (buf && !n)) - return failure(invalid_argument, status); + if (!mangled_name || (buf && !n)) + return failure(invalid_argument, status); - std::string result; - if (mangled_name[0] == '_') - { - // External name? - if (mangled_name[1] == 'Z') - { - // C++ name? - int cnt = session_type:: - decode_encoding(result, mangled_name + 2, INT_MAX); - if (cnt < 0 || mangled_name[cnt + 2] != 0) - return failure(invalid_mangled_name, status); - return finish(result.data(), result.size(), buf, n, status); - } - else if (mangled_name[1] == 'G') + std::string result; + if (mangled_name[0] == '_') { - // Possible _GLOBAL__ extension? - if (!std::strncmp(mangled_name, "_GLOBAL__", 9) - && (mangled_name[9] == 'D' || mangled_name[9] == 'I') - && mangled_name[10] == '_') + // External name? + if (mangled_name[1] == 'Z') { - if (mangled_name[9] == 'D') - result.assign("global destructors keyed to ", 28); - else - result.assign("global constructors keyed to ", 29); - // Output the disambiguation part as-is. - result += mangled_name + 11; + // C++ name? + int cnt = session_type:: + decode_encoding(result, mangled_name + 2, INT_MAX); + if (cnt < 0 || mangled_name[cnt + 2] != 0) + return failure(invalid_mangled_name, status); return finish(result.data(), result.size(), buf, n, status); } + else if (mangled_name[1] == 'G') + { + // Possible _GLOBAL__ extension? + if (!std::strncmp(mangled_name, "_GLOBAL__", 9) + && (mangled_name[9] == 'D' || mangled_name[9] == 'I') + && mangled_name[10] == '_') + { + if (mangled_name[9] == 'D') + result.assign("global destructors keyed to ", 28); + else + result.assign("global constructors keyed to ", 29); + // Output the disambiguation part as-is. + result += mangled_name + 11; + return finish(result.data(), result.size(), buf, n, status); + } + } } - } - // Ambiguities are possible between extern "C" object names and - // internal built-in type names, e.g. "i" may be either an object - // named "i" or the built-in "int" type. Such ambiguities should - // be resolved to user names over built-in names. Builtin types - // are any single lower case character. Any other single - // character is not a mangled type so we can treat those the same - // here. - if (mangled_name[1] == 0) - return finish(mangled_name, 1, buf, n, status); - - // Not a built-in type or external name, try to demangle input as - // NTBS mangled type name. - session_type demangler_session(mangled_name, INT_MAX); - if (!demangler_session.decode_type(result) - || demangler_session.remaining_input_characters()) - { - // Failure to demangle, assume extern "C" name. - result = mangled_name; + // Ambiguities are possible between extern "C" object names and + // internal built-in type names, e.g. "i" may be either an object + // named "i" or the built-in "int" type. Such ambiguities should + // be resolved to user names over built-in names. Builtin types + // are any single lower case character. Any other single + // character is not a mangled type so we can treat those the same + // here. + if (mangled_name[1] == 0) + return finish(mangled_name, 1, buf, n, status); + + // Not a built-in type or external name, try to demangle input as + // NTBS mangled type name. + session_type demangler_session(mangled_name, INT_MAX); + if (!demangler_session.decode_type(result) + || demangler_session.remaining_input_characters()) + { + // Failure to demangle, assume extern "C" name. + result = mangled_name; + } + return finish(result.data(), result.size(), buf, n, status); + } catch (std::bad_alloc&) { + return failure(memory_allocation_failure, status); } - return finish(result.data(), result.size(), buf, n, status); } } // namespace __cxxabiv1