Scribble over alloced and freed memory on platforms using glibc malloc
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 15 May 2014 21:21:00 +0000 (22:21 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 15 May 2014 21:21:00 +0000 (22:21 +0100)
configure
configure.ac
src/lib/debug.c

index 055b7fb..6d97349 100755 (executable)
--- a/configure
+++ b/configure
@@ -8999,6 +8999,7 @@ for ac_func in \
   inet_aton \
   inet_pton \
   inet_ntop \
+  mallopt \
   setlinebuf \
   setvbuf \
   getusershell \
index b33baf2..1cdaf97 100644 (file)
@@ -1309,6 +1309,7 @@ AC_CHECK_FUNCS( \
   inet_aton \
   inet_pton \
   inet_ntop \
+  mallopt \
   setlinebuf \
   setvbuf \
   getusershell \
index 52c65d8..eb0e048 100644 (file)
@@ -690,6 +690,15 @@ int fr_fault_setup(char const *cmd, char const *program)
                        marker = talloc(autofree, bool);
                        talloc_set_destructor(marker, _fr_disable_null_tracking);
                }
+
+               /*
+                *  If were using glibc malloc > 2.4 this scribbles over
+                *  uninitialised and freed memory, to make memory issues easier
+                *  to track down.
+                */
+#if defined(HAVE_MALLOPT) && !defined(NDEBUG)
+               mallopt(M_PERTURB, 0x42);
+#endif
        }
        setup = true;