[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fatal bug in class Thread, thread.cpp line~ 858
From: |
Tobias Erbsland |
Subject: |
fatal bug in class Thread, thread.cpp line~ 858 |
Date: |
Fri, 19 Dec 2003 14:54:47 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 |
Hello
The Thread class has a fatal bug:
==== thread.cpp ==== Line 848 ====
// final can call destructor (that call Terminate)
final();
// test if this class have been deleted
#ifdef WIN32
if (_self.getKey() == this)
#else
if (ThreadImpl::_self.getKey() == this)
#endif
{
if(priv)
priv->_tid = 0;
joinSem.post();
}
====================================
The API documentation suggest to place a "delete this" in the final()
method to delete the thread on exit. This implementation is found for
example in the TCPSession class.
After the final() method, the object could be deleted, so each access to
a member of the object is invalid.
The C++ compiler from the new .NET edition of the MS Visual Studio
(Version 7.0) fills each deleted memory segment with the "word" 0xfeee
in debug mode (i don't know why, but that's the fact).
The line "if(priv)" is true in this case, and the assignment "priv->_tid
= 0" results in an access violation (unix: core dump).
IMHO, instead this strange test, there should be a hook in the virtual
destructor of the Thread class.
regards
Tobias
pgpNMJSq1LtZl.pgp
Description: PGP signature
- fatal bug in class Thread, thread.cpp line~ 858,
Tobias Erbsland <=