]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* libsupc++/vterminate.cc
authorMark Mitchell <mark@codesourcery.com>
Sat, 21 Feb 2004 20:59:26 +0000 (20:59 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sat, 21 Feb 2004 20:59:26 +0000 (20:59 +0000)
(__gnu_cxx::__verbose_terminate_handler): Guard against recursive
calls to terminate.
* src/demangle.cc (__cxa_demangle): Wrap in try-catch block.

From-SVN: r78235

libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/vterminate.cc
libstdc++-v3/src/demangle.cc

index a98b01df820f6066c42dd700bf6801955b6f59c1..e560c6c16bca7f48b292ad7c65832448e48007ff 100644 (file)
@@ -1,3 +1,13 @@
+2004-02-21  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <mark@codesourcery.com>
 
        * testsuite/testsuite_hooks.cc (__gnu_test::set_memory_limits): Do
index 38f6f617868ae3450c0bf9708cbd3313bbc5ba95..0ec9f2ccfe4cf99280435d3ec97a3b2eac0be092 100644 (file)
@@ -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();
index 1221f4cb40b6102d15e00db6a9aa73292abfcc7c..779076d3554b22a295139dff140562a0f6251a9e 100644 (file)
@@ -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<std::allocator<char> > session_type;
+    try {
+      using namespace __gnu_cxx;
+      typedef demangler::session<std::allocator<char> > 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