Boost C++ Libraries: Ticket #5841: thread.cpp: thread_group: possible resource leak between create_thread/add_thread https://svn.boost.org/trac10/ticket/5841 <p> 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. </p> <pre class="wiki">thread* thread_group::create_thread(const function0&lt;void&gt;&amp; threadfunc) { std::auto_ptr&lt;thread&gt; 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&lt;thread*&gt;::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); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5841 Trac 1.4.3 Jeffrey Walton <noloader@…> Wed, 31 Aug 2011 00:45:44 GMT component changed; owner set https://svn.boost.org/trac10/ticket/5841#comment:1 https://svn.boost.org/trac10/ticket/5841#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Fri, 02 Dec 2011 22:45:34 GMT owner, status changed; cc set https://svn.boost.org/trac10/ticket/5841#comment:2 https://svn.boost.org/trac10/ticket/5841#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> The newly created thread inside create thread can not be in any group yet. </p> <p> Respect to add_thread, what should be your preferred behavior when the thread is already in? an exception? </p> <p> Anyway the reference documentation should describes this behavior. </p> Ticket viboes Wed, 07 Dec 2011 00:17:40 GMT type changed https://svn.boost.org/trac10/ticket/5841#comment:3 https://svn.boost.org/trac10/ticket/5841#comment:3 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> </ul> <p> Moved to support request until resolution clarified </p> Ticket viboes Tue, 20 Dec 2011 17:21:00 GMT status, type changed; resolution set https://svn.boost.org/trac10/ticket/5841#comment:4 https://svn.boost.org/trac10/ticket/5841#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>type</strong> <span class="trac-field-old">Support Requests</span> → <span class="trac-field-new">Bugs</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Please, reopen it if you don't agree with the resolution. </p> Ticket