Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#38 ThreadPool heap corruption on Linux MP machines

Platform_Specific
closed
nobody
9
2012-09-14
2006-10-11
No

On multiprocessor Linux machines, ThreadPool can cause
a crash due to a non threadsafe string assignment
corrupting the heap.

Following patch for ThreadPool.cpp fixes this problem:

void PooledThread::run()
{
_started.set();
for (;;)
{
_targetReady.wait();
_mutex.lock();
if (_pTarget) // a NULL target means kill yourself
{
_mutex.unlock();
try
{
_pTarget->run();
}
catch (Exception& exc)
{
ErrorHandler::handle(exc);
}
catch (std::exception& exc)
{
ErrorHandler::handle(exc);
}
catch (...)
{
ErrorHandler::handle();
}
FastMutex::ScopedLock lock(_mutex);
_idle = true;
_idleTime = time(NULL);
_pTarget = 0;
_targetCompleted.set();
ThreadLocalStorage::clear();
_thread.setName(_name);
_thread.setPriority(Thread::PRIO_NORMAL);
}
else
{
_mutex.unlock();
break;
}
}
delete this;
}

Discussion

  • Logged In: YES
    user_id=1148207

    fixed in 1.2.5