From 8e3efcb1dcb27a5b43b66778a6c61681365f945f Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Wed, 11 Mar 2020 15:58:44 +0000 Subject: [PATCH] Assert not going through the PAL (#140) * Assert not going through the PAL * Make it more difficult to assert() accidentally --- src/ds/address.h | 1 - src/ds/bits.h | 1 - src/ds/dllist.h | 1 - src/mem/alloc.h | 2 +- src/test/func/fixed_region/fixed_region.cc | 5 +++++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ds/address.h b/src/ds/address.h index 1c09cd8..49c9b98 100644 --- a/src/ds/address.h +++ b/src/ds/address.h @@ -2,7 +2,6 @@ #include "../pal/pal_consts.h" #include "bits.h" -#include #include namespace snmalloc diff --git a/src/ds/bits.h b/src/ds/bits.h index 71d4e6d..9dc05b0 100644 --- a/src/ds/bits.h +++ b/src/ds/bits.h @@ -9,7 +9,6 @@ #include "defines.h" #include -#include #include #include #if defined(_WIN32) && defined(__GNUC__) diff --git a/src/ds/dllist.h b/src/ds/dllist.h index f892ece..e4e70d2 100644 --- a/src/ds/dllist.h +++ b/src/ds/dllist.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include diff --git a/src/mem/alloc.h b/src/mem/alloc.h index b72f71e..9d14e0a 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -1283,7 +1283,7 @@ namespace snmalloc SNMALLOC_SLOW_PATH void remote_dealloc_slow(RemoteAllocator* target, void* p, sizeclass_t sizeclass) { - assert(target->id() != id()); + SNMALLOC_ASSERT(target->id() != id()); // Now that we've established that we're in the slow path (if we're a // real allocator, we will have to empty our cache now), check if we are diff --git a/src/test/func/fixed_region/fixed_region.cc b/src/test/func/fixed_region/fixed_region.cc index 183ae24..00409cb 100644 --- a/src/test/func/fixed_region/fixed_region.cc +++ b/src/test/func/fixed_region/fixed_region.cc @@ -5,6 +5,11 @@ #include #include +#ifdef assert +# undef assert +#endif +#define assert please_use_SNMALLOC_ASSERT + void* oe_base; void* oe_end; extern "C" const void* __oe_get_heap_base()