From 3d0ba82b8d45dfd3af4f68afcc3255d8e465d8e0 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Wed, 13 Nov 2019 15:34:36 +0000 Subject: [PATCH] Modified pass through If we are using USE_MALLOC pass through, then ThreadAlloc::get() can cause an allocation inside snmalloc still, as it builds the thread local allocator, which allocs a single stub allocator, using the underlying allocator. This means that ASAN would detect a leak in a client, even though the client program has none. This change stops us ever allocating allocators, if we are passing through calls to an underlying allocator. --- src/mem/threadalloc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mem/threadalloc.h b/src/mem/threadalloc.h index b5b24d3..67e011c 100644 --- a/src/mem/threadalloc.h +++ b/src/mem/threadalloc.h @@ -125,11 +125,15 @@ namespace snmalloc */ static SNMALLOC_FAST_PATH Alloc* get() { +#ifdef USE_MALLOC + return get_reference(); +#else auto alloc = get_reference(); auto new_alloc = lazy_replacement(alloc); return (likely(new_alloc == nullptr)) ? alloc : reinterpret_cast(new_alloc); +#endif } };