I'm encountering some problems with the Pseudo Stable Release (0.99 from
3 September 2005). If csEngine::WantToDie is used, the programm crashes
within csMeshList::Remove when trying to access what looks like an
already deleted csMeshWrapper.
This happens in my own program as well as in waltest, just using the
'fire' command in walktest a cupple of times. See crashlog for walktest
(as attachment).
I'm using a clean build with pseudo stable release and matching windows
support libraries from the crystalspace3d.org download site.
I debugged the code a little bit and hopefully found the problem in
plugins\engine\3d\meshobj.cpp:
The methods
bool csMeshList::Remove (iMeshWrapper *obj)
bool csMeshList::Remove (int n)
bool csMeshFactoryList::Remove (iMeshFactoryWrapper *obj)
are deleting objects from their internal list. In some cases this
releases the last counted reference to the object, since almost
everywhere csPtr or plain pointers are used. After the deletion from
list, a change listener is removed. This fails miserably if the object
is already gone.
The person who added the RemoveNameChangeListener calls should revise
similiar changes to check for this kind of bug.
Original code:
bool csMeshList::Remove (iMeshWrapper *obj)
{
FreeMesh (obj);
const char* name = obj->QueryObject ()->GetName ();
if (name)
meshes_hash.Delete (name, obj);
list.Delete (obj);
obj->QueryObject ()->RemoveNameChangeListener (listener);
return true;
}
Corrected code:
bool csMeshList::Remove (iMeshWrapper *obj)
{
FreeMesh (obj);
const char* name = obj->QueryObject ()->GetName ();
if (name)
meshes_hash.Delete (name, obj);
obj->QueryObject ()->RemoveNameChangeListener (listener);
list.Delete (obj); // This may destroy *obj!
return true;
}
Every method that decrements the reference count to an object in some
way may contain this kind of bug or cause it in enclosing method calls.
Philipp
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]