[Warped-devel] Re: Warped errors
Dale E. Martin
dmartin at cliftonlabs.com
Tue Dec 14 22:01:22 EST 2004
> I wasn't aware about this "valgrind" tool. I tracked the bug using gdb
> and many couts throughout the code (I think I should start using some
> advanced technology to debug my programs :-).
Well, add "valgrind" to your list and then you're looking at the three main
tools I use :-)
Doing parallel debugging gets a little more difficult. Did you see the
"SpinBeforeSimulationStart" and "SpinBeforeConfiguration" options in the
warped configuration file? This allows you to run gdb on several nodes at
once to try to ease parallel debugging a little.
> Yes, sort of... The object is deleted, as the operator delete is called,
> but its memory is not deallocated, as the operator is overloaded. But,
> first, look into this code:
> void
> PHOLDObject::reclaimEvent(const Event *event)
> {
> cout << "(Before) Sendtime: " << event->getSendTime() << endl;
> delete event;
> cout << "(After) Sendtime: " << event->getSendTime() << endl;
> }
>
> And this is how the operator delete implementation looks like:
[snip]
> (Before) Sendtime: 5
> (After) Sendtime:
> pure virtual method called. // the program aborts.
OK. There are a couple of possibilities here. One is that you're not
actually getting the allocator stack version of "delete" - did you verify
that it's really what is getting called?
Even if you are, this is a bad idea, as the allocator stack essentially
converts the memory into a blob of a certain size. If some other class is
the same size, you could get those back out of instead of your event class.
Placement new gets called on the blob and suddenly your vtable is gone for
whatever class grabbed this new blob. (It seems unlikely in this case as
there should not be anyone interleaving a "pop" in front of you, but...)
> If I make the method Event::getSendTime() non pure virtual like this:
>
> virtual const VTime &getSendTime() const { cout << "You shouldn't
> be seeing this message !!! " << endl; }
>
> The output of the previous code looks like this:
>
> (Before) Sendtime: 5
> (After) Sendtime: You shouldn't be seeing this message !!!
Did you try valgrind on this? If you can, try it and let me know what it
says.
> So it's proved that the method of the abstract base class is being
> called. But that doesn't bring any error to the Warped execution as I
> changed the code of garbage collecting. I was just wondering how this is
> possible. Maybe there's something related with the AllocatorStack.
Let me know if my explanation makes any sense. In general calling methods
on deleted memory is a Bad Idea, AllocatorStack or not.
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