Jump to content
  • Advertisement
Sign in to follow this  
Dentoid

Crash in 2.13.0

This topic is 3599 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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(¶mBuffer[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. :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Ah, well this class was just an example when I did a repro. In my real case it's a more complex class. :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!