apache / brpc

brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc. "brpc" means "better RPC".
https://brpc.apache.org
Apache License 2.0
16.56k stars 3.98k forks source link

Memory leak? #2792

Closed QiAnXinCodeSafe closed 1 week ago

QiAnXinCodeSafe commented 1 month ago

Hi all, This is Qianxin CodeSafe Team, we found a suspicious issue, at https://github.com/apache/brpc/blob/5cdf22f158722b3b11c7eabb7632690d719ccc4b/src/bthread/task_group.cpp#L230 which is allocating memory at https://github.com/apache/brpc/blob/5cdf22f158722b3b11c7eabb7632690d719ccc4b/src/bthread/task_group.cpp#L81 however,the author did not use any functions to free up memory at https://github.com/apache/brpc/blob/5cdf22f158722b3b11c7eabb7632690d719ccc4b/src/bthread/task_group.cpp#L91 so,there is a memory leak in the pointers 'stk' and 's'.

yanglimingcn commented 4 weeks ago

spans likes a tree,the memory will be destoryed from root, see span.cpp void Span::destroy() { EndAsParent(); traversal(this, [](Span* r) { r->_info.clear(); butil::return_object(r); }); }