-DCLIB_DEBUG => turn on extra checks in dlmalloc 49/13749/2
authorDave Barach <dave@barachs.net>
Thu, 26 Jul 2018 20:16:55 +0000 (16:16 -0400)
committerNeale Ranns <nranns@cisco.com>
Fri, 27 Jul 2018 07:50:11 +0000 (07:50 +0000)
Also: call os_panic() on a heap botch crash, attempt to generate a
post-mortem API dump, etc.

Add an "ugly" test case to vec_test.c, to cause a configurable block
overrun.

Change-Id: I7b29a7645277f9e485e06ff83335306fedc24b71
Signed-off-by: Dave Barach <dave@barachs.net>
build-data/packages/perftool.mk
src/vppinfra/dlmalloc.h
src/vppinfra/test_vec.c

index 992cf53..a549c22 100644 (file)
@@ -13,5 +13,6 @@
 
 perftool_source = src
 
-perftool_configure_args = --disable-vlib --disable-svm --enable-perftool
+perftool_configure_args = --disable-vlib --disable-svm --enable-perftool \
+       --enable-dlmalloc
 
index fbc49e3..b3278f9 100644 (file)
@@ -524,6 +524,17 @@ MAX_RELEASE_CHECK_RATE   default: 4095 unless not HAVE_MMAP
 #include <vppinfra/clib.h>
 #include <vppinfra/cache.h>
 
+/* --- begin vpp customizations --- */
+
+#if CLIB_DEBUG > 0
+#define FOOTERS 1  /* extra debugging */
+#endif
+#define USE_LOCKS 1
+#define DLM_ABORT {extern void os_panic(void); os_panic(); abort();}
+#define ONLY_MSPACES 1
+
+/* --- end vpp customizations --- */
+
 /* Version identifier to allow people to support multiple versions */
 #ifndef DLMALLOC_VERSION
 #define DLMALLOC_VERSION 20806
@@ -587,8 +598,6 @@ MAX_RELEASE_CHECK_RATE   default: 4095 unless not HAVE_MMAP
 /* The maximum possible size_t value has all bits set */
 #define MAX_SIZE_T           (~(size_t)0)
 
-#define USE_LOCKS 1
-
 #ifndef USE_LOCKS /* ensure true if spin or recursive locks set */
 #define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
index ee17ef1..d60d27b 100644 (file)
@@ -1079,6 +1079,7 @@ test_vec_main (unformat_input_t * input)
   uword help = 0;
   uword big = 0;
   uword align = 0;
+  uword ugly = 0;
 
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
@@ -1089,6 +1090,7 @@ test_vec_main (unformat_input_t * input)
          && 0 == unformat (input, "dump %d", &g_dump_period)
          && 0 == unformat (input, "help %=", &help, 1)
          && 0 == unformat (input, "big %=", &big, 1)
+         && 0 == unformat (input, "ugly %d", &ugly)
          && 0 == unformat (input, "align %=", &align, 1))
        {
          clib_error ("unknown input `%U'", format_unformat_error, input);
@@ -1096,6 +1098,19 @@ test_vec_main (unformat_input_t * input)
        }
     }
 
+  /* Cause a deliberate heap botch */
+  if (ugly)
+    {
+      u8 *overrun_me = 0;
+      int i;
+
+      vec_validate (overrun_me, 31);
+      for (i = 0; i < vec_len (overrun_me) + ugly; i++)
+       overrun_me[i] = i;
+
+      vec_free (overrun_me);
+    }
+
   if (big)
     {
       u8 *bigboy = 0;