Hi all,
After a few months out, I just recompiled my C code using the last 1.80 CVS.
Since I’m now experiencing crashes in release mode (optimize 4), I generated a debug P3D environment (with optimize 1) and compiled my code in debug mode.
After a while the program issues :
The assert is triggered at code:
PT(GenericAsyncTask) spy1_task = new GenericAsyncTask("spy1", &SPY_1, (void*) NULL);
taskMgr->add(spy1_task);
Here is the call stack:
msvcr90d.dll!_NMSG_WRITE(int rterrnum=10) Line 198 C
msvcr90d.dll!abort() Line 59 + 0x7 bytes C
msvcr90d.dll!_wassert(const wchar_t * expr=0x00223304, const wchar_t * filename=0x00223240, unsigned int lineno=52) Line 163 C
libp3dtool_d.dll!DeletedBufferChain::allocate(unsigned int size=264, TypeHandle type_handle={...}) Line 52 + 0x1f bytes C++
libpanda_d.dll!DeletedChain<TextureReloadRequest>::allocate(unsigned int size=264, TypeHandle type_handle={...}) Line 28 + 0x25 bytes C++
libpanda_d.dll!StaticDeletedChain<GenericAsyncTask>::allocate(unsigned int size=264, TypeHandle type_handle={...}) Line 143 C++
libpanda_d.dll!GenericAsyncTask::operator new(unsigned int size=264) Line 36 + 0x22 bytes C++
> NED.exe!main(int argc=1, char * * argv=0x03c91518) Line 2514 + 0x2a bytes C++
Apparently during ALLOC_DELETED_CHAIN(GenericAsyncTask);
deletedBufferChain.cxx, line 52
Don’t know what is happening since basically I didn’t change any code for months…
I don’t think you can generate and run a debug p3d file, because the Panda3D build it is downloading is still compiled optimized, so it will be an incompatible binary.
Unless, of course, you are hosting your entire Panda3D build as well, and you have also build that one in debug mode.
Looks like it comes from dynamically allocating an AsyncTask.
I had this piece of code:
Level level(window, *packet);
And I changed it to:
Level* level = new Level(window, *packet)
Level inherits AsyncTask, and since I went from the first line to the second, I have the same error and same backtrace,
Any clue on why it may happen ?
This can reproduce the issue:
class Test : public AsyncTask
{
public:
Test() : AsyncTask()
{
}
DoneStatus do_task()
{
}
private:
int lol;
};
int main(void)
{
new Test();
return (0);
}
From the DeletedChain class description, from which AsyncTask inherits:
// Of course, this trick of maintaining the deleted
// object chain won't work in the presence of
// polymorphism, where you might have many classes that
// derive from a base class, and all of them have a
// different size--unless you instantiate a DeletedChain
// for *every* kind of derived class. The
// ALLOC_DELETED_CHAIN macro, below, is designed to make
// this easy.
Look in asyncTask.h for how ALLOC_DELETED_CHAIN is used.
Also, keep in mind that AsyncTask is reference counted, so use PT()s around your pointer.