/*--- Memory pool stuff. ---*/
/*------------------------------------------------------------*/
+/* Set to 1 for intensive sanity checking. Is very expensive though
+ and should not be used in production scenarios. See #255966. */
+#define MP_DETAILED_SANITY_CHECKS 0
+
+static void check_mempool_sane(MC_Mempool* mp); /*forward*/
+
+
void MC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed)
{
MC_Mempool* mp;
mp->rzB = rzB;
mp->is_zeroed = is_zeroed;
mp->chunks = VG_(HT_construct)( "MC_(create_mempool)" );
+ check_mempool_sane(mp);
/* Paranoia ... ensure this area is off-limits to the client, so
the mp->data field isn't visible to the leak checker. If memory
MC_(record_illegal_mempool_error) ( tid, pool );
return;
}
+ check_mempool_sane(mp);
// Clean up the chunks, one by one
VG_(HT_ResetIter)(mp->chunks);
if (mp == NULL) {
MC_(record_illegal_mempool_error) ( tid, pool );
} else {
- check_mempool_sane(mp);
+ if (MP_DETAILED_SANITY_CHECKS) check_mempool_sane(mp);
MC_(new_block)(tid, addr, szB, /*ignored*/0, mp->is_zeroed,
MC_AllocCustom, mp->chunks);
- check_mempool_sane(mp);
+ if (MP_DETAILED_SANITY_CHECKS) check_mempool_sane(mp);
}
}
VG_(get_and_pp_StackTrace) (tid, MEMPOOL_DEBUG_STACKTRACE_DEPTH);
}
- check_mempool_sane(mp);
+ if (MP_DETAILED_SANITY_CHECKS) check_mempool_sane(mp);
mc = VG_(HT_remove)(mp->chunks, (UWord)addr);
if (mc == NULL) {
MC_(record_free_error)(tid, (Addr)addr);
}
die_and_free_mem ( tid, mc, mp->rzB );
- check_mempool_sane(mp);
+ if (MP_DETAILED_SANITY_CHECKS) check_mempool_sane(mp);
}
if (VG_(HT_remove)(mp->chunks, (UWord)mc->data) == NULL) {
MC_(record_free_error)(tid, (Addr)mc->data);
VG_(free)(chunks);
- check_mempool_sane(mp);
+ if (MP_DETAILED_SANITY_CHECKS) check_mempool_sane(mp);
return;
}
die_and_free_mem ( tid, mc, mp->rzB );
if (VG_(HT_remove)(mp->chunks, (UWord)mc->data) == NULL) {
MC_(record_free_error)(tid, (Addr)mc->data);
VG_(free)(chunks);
- check_mempool_sane(mp);
+ if (MP_DETAILED_SANITY_CHECKS) check_mempool_sane(mp);
return;
}