wwbmmm commented on code in PR #2890: URL: https://github.com/apache/brpc/pull/2890#discussion_r1948349732
########## src/bthread/task_group.cpp: ########## @@ -255,6 +297,15 @@ int TaskGroup::init(size_t runqueue_capacity) { return 0; } +#ifdef BUTIL_USE_ASAN +void TaskGroup::bthread_task_runner(intptr_t) { Review Comment: 叫asan_task_runner是不是更合适? ########## src/butil/object_pool_inl.h: ########## @@ -85,6 +86,29 @@ class ObjectPoolBlockItemNum { template <typename T> class BAIDU_CACHELINE_ALIGNMENT ObjectPool { +private: +#ifdef BUTIL_USE_ASAN + static void asan_poison_memory_region(T* ptr) { + if (!ObjectPoolWithASanPoison<T>::value || NULL == ptr) { + return; + } + // Marks the object as addressable. + BUTIL_ASAN_POISON_MEMORY_REGION(ptr, sizeof(T)); + } + static void asan_unpoison_memory_region(T* ptr) { + if (!ObjectPoolWithASanPoison<T>::value || NULL == ptr) { + return; + } + // Marks the object as unaddressable. + BUTIL_ASAN_UNPOISON_MEMORY_REGION(ptr, sizeof(T)); + } +#define OBJECT_POOL_ASAN_POISON_MEMORY_REGION(ptr) asan_poison_memory_region(ptr) +#define OBJECT_POOL_ASAN_UNPOISON_MEMORY_REGION(ptr) asan_unpoison_memory_region(ptr) +#else + #define OBJECT_POOL_ASAN_POISON_MEMORY_REGION(ptr) ((void)(ptr)) Review Comment: 好像多了个缩进 ########## test/bthread_execution_queue_unittest.cpp: ########## @@ -225,7 +227,9 @@ void test_performance(bool use_pthread) { pa.total_time = 0; pa.expected_value = 0; pa.stopped = false; +#ifdef BRPC_WITH_GPERFTOOLS Review Comment: 是不是可以搞一个公共适配头文件,如果定义了BRPC_WITH_GPERFTOOLS就直接使用gperftools_profiler.h,如果没有定义就实现一个空的ProfilerStart/ProfilerStop函数,这样不用改太多地方 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org