Closed eVen-p closed 1 year ago
hi,我在使用Address sanitizer做内存泄露检测时,使用了类似下面的简单例子:
#include “co/co.h" #include <iostream> int main() { go( [] { std::cout << "hi"; } ); return 0; }
得到了如下的内存泄露报告
============================================= ==11741==ERROR: LeakSanitizer: detected memory leaks Direct leak of 12288 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3b82e in calloc (/lib64/libasan.so.5+0xl0c82e) # 1 0x7fd57c8dlO61 in co::Epoll::Epoll(int) /libcoost-3.0.0/src/co/epol1/epol1. cc:20 # 2 0x7fd57c90674e in co::Epoll* co::make<co::Epoll, unsigned int&>(unsigned int&) /libcoost-3.0.0/include/co/mem.h:45 # 3 0x7fd57c90674e in co::schedulerImpl::schedulerImpl(unsigned int, unsigned int, unsigned int) /libcoost-3.0.0/src/co/scheduler.cc:20 # 4 0x7fd57c9119fb in co::schedulerManager::schedulerManager() /libcoost-3.0.0/src/co/scheduler.cc:240 # 5 0x7fd57c9125dO in co::schedulerManager* co::static_new<co::schedulerManager>() /opt/rh/devtoolset-8/root/usr/include/c++/8/new:169 # 6 0x7fd57c9125dO in co::scheduler_manager() /libcoost-3.0.0/src/co/scheduler. cc:253 # 7 0x7fd57c9125dO in co::go(co::closure*) /libcoost-3.0.0/src/co/scheduler.cc:281 # 8 0x40280a in void co::go<main::{lambda()#l}>(main::{lambda()#l}&&) (/test/out/test+0x40280a) # 9 0x40255f in main (/test/out/test+0x40255f) # 10 0x7fd57bccl554 in 1ibc_start_main ../csu/libc-start.c:266 Direct leak of 48 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3d36f in operator new(unsigned long) (/lib64/libasan.so.5+0xl0e36f) # 1 0x7fd57c98f5e9 in co::xx::thread_alloc() /libcoost-3.0.0/src/mem.cc:532 # 2 0x7fd57c98f5e9 in co::free(void*, unsigned long) /libcoost-3.0.0/src/mem.cc:759 # 3 0x7fd57c912d84 in Thread::_thread_fun(void*) /libcoost-3.0.0/include/co/thread.h:251 # 4 0x7fd57b67eea4 in start_thread /usr/src/debug/glibc-2.17-c758a686/nptl/pthread_create.c:307 Direct leak of 48 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3d36f in operator new(unsigned long) (/lib64/libasan.so.5+0xl0e36f) # 1 0x7fd57c98ef79 in co::xx::thread_alloc() /libcoost-3.0.0/src/mem.cc:532 # 2 0x7fd57c98ef79 in co::alloc(unsigned long) /libcoost-3.0.0/src/mem.cc:755 # 3 0x7fd57c90a86c in co::Schedulerlmpl::resume(co:Coroutine*) /libcoost-3.0.0/src/co/scheduler.cc:67 # 4 0x7fd57c90ebl0 in co::schedulerImpl::loop() /libcoost-3.0.0/src/co/scheduler.cc:165 # 5 0x7fd57c912d24 in co::xx::Method0<Taskedlmpl>::run() /libcoost-3.0.0/include/co/closure.h:92 # 6 0x7fd57c912d24 in Thread::_thread_fun(void*) /libcoost-3.0.0/include/co/thread.h:251 # 7 0x7fd57b67eea4 in start_thread /usr/src/debug/glibc-2.17-c758a686/nptl/pthread_create.c:307 Direct leak of 1048576 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3b82e in calloc (/lib64/libasan.so.5+0xl0c82e) # 1 0x7fd57c906351 in co::table<co::coroutine>::table(int, int) /libcoost-3.0.0/include/co/table.h:27 # 2 0x7fd57c906351 in co::copool::copool() /libcoost-3.0.0/src/co/scheduler.h:lll # 3 0x7fd57c906351 in co::SchedulerImpl::schedulerImpl(unsigned int, unsigned int, unsigned int) /libcoost-3.0.0/src/co/scheduler.cc:19 # 4 0x7fd57c9119fb in co::SchedulerManager::schedulerManager() /libcoost-3.0.0/src/co/scheduler.cc:240 # 5 0x7fd57c9125d0 in co::SchedulerManager* co::static_new<co::schedulerManager>() /opt/rh/devtoolset-8/root/usr/include/c++/8/new:169 # 6 0x7fd57c9125d0 in co::scheduler_manager() /libcoost-3.0.0/src/co/scheduler.cc:253 # 7 0x7fd57c9125d0 in co::go(co::closure*) /libcoost-3.0.0/src/co/scheduler.cc:281 # 8 0x40280a in void co::go<main::{lambda()#l}>(main::{lambda()#l}&&) (/test/out/test+0x40280a) # 9 0x40255f in main (/test/out/test+0x40255f) # 10 0x7fd57bccl554 in libc_start_main ../csu/libc-start.c:266 Indirect leak of 1048576 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3b638 in interceptor_malloc (/lib64/libasan.so.5+0xl0c638) # 1 0x7fd57c9938e7 in co::xx::TnreadAlloc::alloc(unsigned long) /libcoost-3.0.0/src/mem.cc:671 # 2 0x7fd57c90a86c in co::SchedulerImpl::resume(co::coroutine ) /libcoost-3.0.0/src/co/scheduler.cc:67 # 3 0x7fd57c90ebl0 in co::SchedulerImpl::loop() /libcoost-3.0.0/src/co/scheduler.cc:165 # 4 0x7fd57c912d24 in co::xx::Method0<TaskedImpl>::run() /libcoost-3.0.0/include/co/closure.h:92 # 5 0x7fd57c912d24 in Thread::_thread_fun(void*) /libcoost-3.0.0/include/co/thread.h:251 # 6 0x7fd57b67eea4 in start_thread /usr/src/debug/glibc-2.17-c758a686/nptl/pthread_create.c:307 Indirect leak of 131072 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3b82e in calloc (/lib64/libasan.so.5+0xl0c82e) # 1 0x7fd57c9O631f in co::table<co::coroutine>::table(int, int) /libcoost-3.0.0/include/co/table.h:26 # 2 0x7fd57c9O631f in co::copool::copool() /libcoost-3.0.0/src/co/scheduler.h:111 # 3 0x7fd57c9O631f in co::SchedulerImpl::schedulerImpl(unsigned int, unsigned int, unsigned int) /libcoost-3.0.0/src/co/scheduler.cc:19 # 4 0x7fd57c9119fb in co::SchedulerManager::SchedulerManager() /libcoost-3.0.0/src/co/scheduler. cc:240 # 5 0x7fd57c9125d0 in co::SchedulerManager* co::static_new<co::schedulerManager>() /opt/rh/devtoolset-8/root/usr/include/c++/8/new:169 # 6 0x7fd57c9125d0 in co::scheduler_manager() /libcoost-3.0.0/src/co/scheduler.cc:253 # 7 0x7fd57c9125d0 in co::go(co::closure*) /libcoost-3.0.0/src/co/scheduler.cc:281 # 8 0x40280a in void co::go<main::{lambda()#l}>(main::{lambda()#l}&&) (/test/out/test+0x40280a) # 9 0x40255f in main (/test/out/test+0x40255f) # 10 0x7fd57bccl554 in 1ibc start main ../csu/libc-start.c:266 Indirect leak of 408 byte(s) in 1 object(s) allocated from: # 0 0x7fd57cd3d36f in operator new(unsigned long) (/lib64/libasan.so.5+0xl0e36f) # 1 0x7fd57c911990 in co::SchedulerManager::schedulerManager() /libcoost-3.0.0/src/co/scheduler.cc:240 # 2 0x7fd57c9125d0 in co::SchedulerManager* co::static_new<co::schedulerManager>() /opt/rh/devtoolset-8/root/usr/include/c++/8/new:169 # 3 0x7fd57c9125d0 in co::scheduler_manager() /libcoost-3.0.0/src/co/scheduler.cc:253 # 4 0x7fd57c9125d0 in co::go(co::closure*) /libcoost-3.0.0/src/co/scheduler.cc:281 # 5 0x40280a in void co::go<main::{lambda()#l}>(main::{lambda()#l}&&) (/test/out/test+0x40280a) # 6 0x40255f in main (/test/out/test+0x40255f) # 7 0x7fd57bccl554 in __1ibc_start_main ../csu/libc-start.c:266 SUMMARY: Addresssanitizer: 2241016 byte(s) leaked in 7 allocation(s).
这样的现象是正常的吗
正常的
好的
hi,我在使用Address sanitizer做内存泄露检测时,使用了类似下面的简单例子:
得到了如下的内存泄露报告
这样的现象是正常的吗