Crash in 2.13.0

Started by
2 comments, last by WitchLord 15 years, 9 months ago
Hey I think I hit a bug in AS 2.13.0 (or I've registered something wrong). In my real case it's more complex, but I managed to reproduce it like this: 1. Register a very simple class

engine->RegisterObjectType( "Test", sizeof(float), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_C );
(For testing I just pretend a float is a custom class.) 2. Register an operator for it:

engine->RegisterGlobalBehaviour( asBEHAVE_ADD, "Test f(Test &in, Test &in)", asFUNCTION(add), asCALL_CDECL);
("add" is just implemented as a simple add operator for floats) 3. Register a function with 2+ arguments of our type:

engine->RegisterGlobalFunction("void doStuff(Test, Test)", asFUNCTION(doStuff), asCALL_CDECL);
(This function can to whatever, it'll never enter it anyway. :) 4. Make a simple script function that declares two variables of our class, and runs "doStuff" on it:

Test test1, test2;
doStuff( test1, test1 + test2 ); // This one will work
doStuff( test1 + test2, test1 ); // This one will blow
The second one crashes in as_callfunc_x86.cpp:298

memcpy(&paramBuffer[dpos], *(void**)(args+spos), descr->parameterTypes[n].GetSizeInMemoryBytes());
This is where it makes a copy of the argument, but the second argument (the "test1") has already been freed (I've traced it and it's freed, I think somewhere between the argument evaluation and the actual function call, but I'm not totally sure.) I don't know why this is happening and I'm not familiar enough with the compiler to figure it out, but the repro case is fairly easy. Shout if you need any more details. :)
Advertisement
Looks like it could be the same bug reported here: http://www.gamedev.net/community/forums/topic.asp?topic_id=498893

I'll investigate it as soon as possible.



I noticed one thing that's wrong with your registration. When calling RegisterObjectType you should be using asOBJ_APP_FLOAT instead of asOBJ_APP_CLASS_C. Doesn't look like this is related to the bug though.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Ah, well this class was just an example when I did a repro. In my real case it's a more complex class. :)
The bug fix is now available in the SVN (rev 279)

It was indeed the same bug that loboWu had reported in the other thread.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement