Subject: [Boost-bugs] [Boost C++ Libraries] #5841: thread.cpp: thread_group: possible resource leak between create_thread/add_thread
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-30 06:59:26
#5841: thread.cpp: thread_group: possible resource leak between
create_thread/add_thread
--------------------------------+-------------------------------------------
Reporter: noloader@⦠| Owner:
Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
Version: Boost 1.47.0 | Severity: Problem
Keywords: |
--------------------------------+-------------------------------------------
If add_thread finds the newly created thread in its list, it will not add
the thread. However, the thread/pointer will not be properly disposed. In
addition, create_thread will return a value which indicates success
regardless of the result of add_thread.
{{{
thread* thread_group::create_thread(const function0<void>& threadfunc)
{
std::auto_ptr<thread> thrd(new thread(threadfunc));
add_thread(thrd.get());
return thrd.release();
}
void thread_group::add_thread(thread* thrd)
{
mutex::scoped_lock scoped_lock(m_mutex);
// For now we'll simply ignore requests to add a thread object
multiple
// times. Should we consider this an error and either throw or return
an
// error value?
std::list<thread*>::iterator it = std::find(m_threads.begin(),
m_threads.end(), thrd);
assert(it == m_threads.end());
if (it == m_threads.end())
m_threads.push_back(thrd);
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5841> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC