From 753d83c78594c3cce7d5ac35900af9b3a0ed31ca Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 8 Jun 2021 15:53:02 +0200 Subject: [PATCH] Die loudly if smpi_shared_realloc_intercept is used. --- include/smpi/sampi.h | 1 + include/smpi/smpi_helpers.h | 1 + include/smpi/smpi_helpers_internal.h | 1 + src/smpi/internals/smpi_shared.cpp | 7 +++++++ 4 files changed, 10 insertions(+) diff --git a/include/smpi/sampi.h b/include/smpi/sampi.h index dc5095eeb5..dd94dee0c8 100644 --- a/include/smpi/sampi.h +++ b/include/smpi/sampi.h @@ -17,6 +17,7 @@ #ifndef HAVE_SMPI #undef malloc #undef calloc +#undef realloc #undef free // Internally disable these overrides (HAVE_SMPI is only defined when building the library) #define malloc(nbytes) _sampi_malloc(nbytes) diff --git a/include/smpi/smpi_helpers.h b/include/smpi/smpi_helpers.h index 68df20ff9b..ef7492d998 100644 --- a/include/smpi/smpi_helpers.h +++ b/include/smpi/smpi_helpers.h @@ -35,6 +35,7 @@ #ifndef SMPI_NO_OVERRIDE_MALLOC #define malloc(x) smpi_shared_malloc_intercept((x), __FILE__, __LINE__) #define calloc(x, y) smpi_shared_calloc_intercept((x), (y), __FILE__, __LINE__) +#define realloc(x, y) smpi_shared_realloc_intercept((x), (y), __FILE__, __LINE__) #define free(x) smpi_shared_free(x) #endif #endif diff --git a/include/smpi/smpi_helpers_internal.h b/include/smpi/smpi_helpers_internal.h index 404d1cbcee..25a4f7093b 100644 --- a/include/smpi/smpi_helpers_internal.h +++ b/include/smpi/smpi_helpers_internal.h @@ -36,6 +36,7 @@ int smpi_getopt(int argc, char* const* argv, const char* options); void* smpi_shared_malloc_intercept(size_t size, const char* file, int line); void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line); +void* smpi_shared_realloc_intercept(void* data, size_t size, const char* file, int line); void smpi_shared_free(void* data); #ifdef __cplusplus } // extern "C" diff --git a/src/smpi/internals/smpi_shared.cpp b/src/smpi/internals/smpi_shared.cpp index dfc99b8446..7ba2950fca 100644 --- a/src/smpi/internals/smpi_shared.cpp +++ b/src/smpi/internals/smpi_shared.cpp @@ -333,6 +333,13 @@ void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* } } +void* smpi_shared_realloc_intercept(void* /*data*/, size_t /*size*/, const char* file, int line) +{ + // FIXME + XBT_ERROR("%s:%d: using realloc() with SMPI malloc interception is currently not supported", file, line); + xbt_die("Please recompile with -DSMPI_NO_OVERRIDE_MALLOC"); +} + void* smpi_shared_malloc(size_t size, const char* file, int line) { if (size > 0 && smpi_cfg_shared_malloc() == SharedMallocType::LOCAL) { -- 2.20.1