[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bugs in class Thread. The Pointer to a deleted resource must be set to 0
From: |
Tobias Erbsland |
Subject: |
Bugs in class Thread. The Pointer to a deleted resource must be set to 0 |
Date: |
Fri, 19 Dec 2003 15:38:21 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 |
Hello
There are some bugs the the class Thread. I found the first example in
DummyThread. Code snipplet:
void DummyThread::CheckDelete()
{
Thread *th = (Thread*)_self.getKey();
if (!th) return;
// delete if dummy thread
if (th->priv->_type == threadTypeDummy)
delete th;
}
I could be that the dummy thread is deleted multible times.
The function should be:
void DummyThread::CheckDelete()
{
Thread *th = (Thread*)_self.getKey();
if (!th) return;
// delete if dummy thread
if (th->priv->_type == threadTypeDummy)
{
delete th;
th = 0; // <---------- !!!
}
}
The same fault in the function "terminate()":
void Thread::terminate(void)
{
#ifdef WIN32
if(!priv)
return;
if (!priv->_tid || isThread())
return;
// (....)
delete priv;
}
first call of terminate deletes the resouce pointed by priv. Second call
crashes, because the pointer sill points to the deleted resource:
delete priv;
priv = 0; // <---!!!
}
solves this problem.
Same Problem again:
// delete Thread class created for no CommonC++ thread
inline void ThreadImpl::ThreadDestructor(Thread* th)
{
if (!th || th == DUMMY_INVALID_THREAD)
return;
if (th->priv->_type == threadTypeDummy)
delete th;
}
Same problems in the class Poller also.
regards
Tobias
pgpWrbvelRcYD.pgp
Description: PGP signature
- Bugs in class Thread. The Pointer to a deleted resource must be set to 0,
Tobias Erbsland <=