From 5fc76bd28960605eabe7334f23b77998c615a039 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Fri, 2 Jun 2017 12:32:01 -0700 Subject: [PATCH] Fix JemallocNodumpAllocator extent_hooks API. Summary: Using extent_hooks mallctl to update hooks. Reviewed By: jasone Differential Revision: D5174623 fbshipit-source-id: 9313ee9ae55c85d973736077727e54a5825f4c3d --- folly/experimental/JemallocNodumpAllocator.cpp | 7 ++++++- folly/experimental/JemallocNodumpAllocator.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/folly/experimental/JemallocNodumpAllocator.cpp b/folly/experimental/JemallocNodumpAllocator.cpp index e2ce6d8c..8d29dbc8 100644 --- a/folly/experimental/JemallocNodumpAllocator.cpp +++ b/folly/experimental/JemallocNodumpAllocator.cpp @@ -89,7 +89,12 @@ bool JemallocNodumpAllocator::extend_and_setup_arena() { } // Set the custom hook - hooks->alloc = &JemallocNodumpAllocator::alloc; + extent_hooks_ = *hooks; + extent_hooks_.alloc = &JemallocNodumpAllocator::alloc; + if (auto ret = + mallctl(key.c_str(), nullptr, nullptr, &hooks, sizeof(hooks))) { + LOG(FATAL) << "Unable to set the hooks: " << errnoStr(ret); + } #endif return true; diff --git a/folly/experimental/JemallocNodumpAllocator.h b/folly/experimental/JemallocNodumpAllocator.h index 487a06b9..a87161f0 100644 --- a/folly/experimental/JemallocNodumpAllocator.h +++ b/folly/experimental/JemallocNodumpAllocator.h @@ -91,6 +91,7 @@ class JemallocNodumpAllocator { static void* alloc( void* chunk, #else + extent_hooks_t extent_hooks_; static extent_alloc_t* original_alloc_; static void* alloc( extent_hooks_t* extent, -- 2.34.1