Closed venjun2000 closed 5 years ago
Thanks for the report. Have you analyzed the report? Are you sure there is a real leak? How are you sure this function 'thread_exit_func' is not called? isn't this a false positive?
@viboes , Here's the report..
840 void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr
**CID 1588763 (#1 of 1): Resource leak (RESOURCE_LEAK)
I don't see from the report why there is a memory leak.
I don't see from the report why there is a memory leak.
Can you confirm whether there is leak or is it false positive ? Is it something like the user of this library will free the storage allocated ? Is this library designed like this ?
The library free the storage at thread exit. Is Coverity checking it after the thread exits? IIUC Coverity is a static analysis tool, not a run-time one. I don't know how it can tell for sure that this function will not be called.
I ran valgrind --leak-check=full test_thread_exit
(test_thread_exit.cpp is in the Boost.Thread test folder) against the latest develop branch and it reported that 0 bytes were leaked. The Coverity finding is a false positive. The memory is freed here:
https://github.com/boostorg/thread/blob/develop/src/pthread/thread.cpp#L104
Issue location: https://github.com/boostorg/thread/blob/boost-1.61.0/include/boost/thread/detail/thread.hpp#L859
Coverity tool detects and reports as major issue
Resource leak /DeliSpace/TegraP1Lin.Rel/External/Boost/inc/boost/thread/detail/thread.hpp at_thread_exit