This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [google gcc-4_7, integration] Scribble on destructed strings to catch invalid accesses.


On 24/01/13 19:03, Marc Glisse wrote:
On Wed, 23 Jan 2013, Paul Pluzhnikov wrote:

This patch allows us to catch use of destructed strings.

Hello,


while a number of the google debug patches are just cheaper versions (that don't break the ABI) of what libstdc++'s debug mode provides, this overwriting of classes on destruction is not as obviously redundant, and I wonder whether something like it (done consistently for many classes) could go to trunk...

A possibly crazy suggestion.. How hard would it be to add this automatically to all calls to destructors? (via a command line flag obviously)


Chris


Google ref: b/5430313

Ok for google/gcc-4_7 and google/integration?

--
Paul Pluzhnikov



Index: libstdc++-v3/include/ext/sso_string_base.h
===================================================================
--- libstdc++-v3/include/ext/sso_string_base.h    (revision 195417)
+++ libstdc++-v3/include/ext/sso_string_base.h    (working copy)
@@ -215,7 +215,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              const _Alloc& __a);

      ~__sso_string_base()
-      { _M_dispose(); }
+      {
+          _M_dispose();
+#ifdef __google_stl_debug_dangling_string
+          __builtin_memset(this, 0xcd, sizeof(*this));
+#endif
+      }

      _CharT_alloc_type&
      _M_get_allocator()



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]