[Warped-devel] Re: Warped errors
Dale E. Martin
dmartin at cliftonlabs.com
Mon Dec 13 17:29:45 EST 2004
> This one was tough... But I kind of figured out what was going on.
> Actually, it was tough to figure out where the problem was, as the
> solution is pretty simple.
Wow, thanks for tracking that one down - those kinds of bugs are hard to
find. If you're not already aware of "valgrind" use google to find it and
try it out. It might have helped in this case.
BTW, as I mentioned in private mail I'm working on integrating your new
version of phold. (Partly so I could look into this problem with you.)
> To correct the problem I modified the code of
> TimeWarpSimulationManager.cpp to make the OutputManagers of all
> objects to collect their garbage (in a different loop) before the
> Eventsets deletes the objects. Here's how the new code looks like:
>
> ...
> void
> TimeWarpSimulationManager::garbageCollect(const VTime& garbageCollectTime){
> ...
> for( unsigned int i = 0; i < objects->size(); i++ ){
> myStateManager->garbageCollect(garbageCollectTime, (*objects)[i]);
> myOutputManager->garbageCollect(garbageCollectTime, (*objects)[i]);
> }
>
> for( unsigned int i = 0; i < objects->size(); i++ ){
> myEventSet->garbageCollect( (*objects)[i], garbageCollectTime );
> ...
When I commit your phold example this fix will be committed as well.
> It seems the problem is corrected, but I'd still like to know why is
> the system losing the "dynamic binding" of virtual functions when the
> object is inserted on the stack!
If I understand your analysis correctly, the object is deleted and then the
dangling pointer is pushed onto the stack. The memory pointed to by the
dangling pointer will then get reused. Next time the dangling pointer gets
accessed, the vtable pointer for the Event class is assumed but it's been
overwritten so you get one of those two crashes.
"valgrind" eases finding these kinds of errors. You're seeing that you are
one of the first people to try to push a real application through the
current version of warped running in parallel mode. Thanks for finding and
debugging this issue!
Take care,
Dale
--
Dale E. Martin, Clifton Labs, Inc.
Senior Computer Engineer
dmartin at cliftonlabs.com
http://www.cliftonlabs.com
pgp key available
More information about the warped-devel
mailing list