[CrystalSpace] #974: Race in csThreadManager::PushToQueue
"CrystalSpace" <[email protected]> Sun, 03 Mar 2013 19:54:50 -0000
| Newsgroups | gmane.comp.graphics.crystalspace.tracker |
|---|---|
| Message-ID | <[email protected]> |
#974: Race in csThreadManager::PushToQueue
---------------------------+------------------------------------------------
Reporter: ralphcampbell | Owner: admin
Type: defect | Status: new
Priority: major | Milestone:
Component: libs | Version: V2.1
Keywords: |
---------------------------+------------------------------------------------
The mutex lock is not held while scanning the array of waitingThreads.
This can lead to the array boundary assertion being hit if an entry is
deleted while scanning the array (when CS_DEBUG is enabled).
Since the NotifyAll() sets a condition variable, it seems safe to
me to be called while holding the waitingThreadsLock.
The suggested fix is to make the lock cover the for loop.
I found this while running planeshift and the background loader hit the
array assertion. I made the suggested fix and it seems to be
working better.
{{{
Index: include/csutil/threadmanager.h
===================================================================
--- include/csutil/threadmanager.h (revision 39160)
+++ include/csutil/threadmanager.h (working copy)
@@ -73,11 +73,8 @@
{
if(queueType == THREADED || queueType == THREADEDL)
{
- {
- CS::Threading::MutexScopedLock lock(waitingThreadsLock);
- threadQueue->Enqueue(job);
- }
-
+ CS::Threading::MutexScopedLock lock(waitingThreadsLock);
+ threadQueue->Enqueue(job);
for(size_t i=0; i<waitingThreads.GetSize(); ++i)
{
waitingThreads[i]->NotifyAll();
}}}
--
Ticket URL: <http://www.crystalspace3d.org/trac/CS/ticket/974>
CrystalSpace <http://www.crystalspace3d.org/>
Free open-source 3D SDK.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb