Opened 11 years ago
Closed 11 years ago
#5841 closed Bugs (invalid)
thread.cpp: thread_group: possible resource leak between create_thread/add_thread
| Reported by: | Owned by: | viboes | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | thread |
| Version: | Boost 1.47.0 | Severity: | Problem |
| Keywords: | Cc: | viboes |
Description
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);
}
Change History (4)
comment:1 by , 11 years ago
| Component: | None → thread |
|---|---|
| Owner: | set to |
comment:2 by , 11 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:3 by , 11 years ago
| Type: | Bugs → Support Requests |
|---|
Moved to support request until resolution clarified
comment:4 by , 11 years ago
| Resolution: | → invalid |
|---|---|
| Status: | assigned → closed |
| Type: | Support Requests → Bugs |
Please, reopen it if you don't agree with the resolution.
Note:
See TracTickets
for help on using tickets.

The newly created thread inside create thread can not be in any group yet.
Respect to add_thread, what should be your preferred behavior when the thread is already in? an exception?
Anyway the reference documentation should describes this behavior.