Jump to content
  • Advertisement
Sign in to follow this  
_Vicious_

Assertion failure in as_configgroup.cpp

This topic is 2510 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

Advertisement
It means that something didn't go as I had expected when writing the code. It is quite possible a bug in my code, though as it is in the ValidateNoUsage() method it is possible it doesn't affect your application if you compile the library in release mode.

Do you know how to reproduce the problem? I'll need to know this in order to debug it and fix the code.

Thanks,
Andreas

Share this post


Link to post
Share on other sites
It never happens for me, and I always test in debug mode.

I'll need help to narrow it down. As it is now I have no idea what the problem might be.

Is it possible for you to create a small test that reproduce the problem?

Share this post


Link to post
Share on other sites
On a side note, I've also hit an assertion failure in as_array.h:
asASSERT(index < length);

in asCArray<T>::operator []

The values for index and length are 388 and 76 respectively.

This is the faulty line:
return registeredGlobalFuncs[id];

in asCScriptEngine::GetGlobalFunctionByDecl

Share this post


Link to post
Share on other sites
This one is easier. The faulty line should be changed to:

return scriptFunctions[id];

I've checked in this fix in revision 1115.

Thanks,
Andreas

Share this post


Link to post
Share on other sites
I think the reason for the first error was that I was trying to do something unexpected for the AS :)
Basically, I wanted to be able to call function pointer in this manner:

other.pain( other, ent, 10.9, 10.0 );


for objects that had the .pain callback set in the C code (in the game not all of the game objects are controlled through scripting). For that, I created a proxy function:

void G_CallPain( edict_t *ent, edict_t *attacker, float kick, float damage )
{
if( ent->pain )
ent->pain( ent, attacker, kick, damage );
else if( ent->scriptSpawned && ent->asPainFunc )
G_asCallMapEntityPain( ent, attacker, kick, damage );
}

, registered it in AS as a global function and then set the asPainFunc function pointer in AddRef method like this:

if( !obj->scriptSpawned ) {
obj->asPainFunc = asEntityCallPainFuncPtr;


The key thing is that asPainFunc also holds the .pain function pointer set from the script.

Share this post


Link to post
Share on other sites
This should work.

I'll make some new tests with this info and see if it allows me to reproduce the problem.



How is the G_CallPain function registered? It is a global function in the application but you seem to call it as if it was an object method in the script.

Share this post


Link to post
Share on other sites
I'm still not able to reproduce the problem. I wrote the following test in the hopes that a funcdef in a dynamic config group may have been the cause.



{
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);

engine->BeginConfigGroup("gr");
engine->RegisterObjectType("type", 0, asOBJ_REF);
engine->RegisterObjectBehaviour("type", asBEHAVE_FACTORY, "type @f()", asFUNCTION(Type::Factory), asCALL_CDECL);
engine->RegisterObjectBehaviour("type", asBEHAVE_ADDREF, "void f()", asMETHOD(Type,AddRef), asCALL_THISCALL);
engine->RegisterObjectBehaviour("type", asBEHAVE_RELEASE, "void f()", asMETHOD(Type,Release), asCALL_THISCALL);
engine->RegisterFuncdef("void fun(type @, int)");
engine->RegisterObjectProperty("type", "fun @callback", asOFFSET(Type,callback));
engine->EndConfigGroup();

asIScriptModule *mod = engine->GetModule("mod", asGM_ALWAYS_CREATE);
mod->AddScriptSection("s",
"void func(type @, int) {} \n"
"void main() \n"
"{ \n"
" type t; \n"
" @t.callback = func; \n"
" t.callback(t, 1); \n"
"} \n");

int r = mod->Build();
if( r < 0 )
TEST_FAILED;

r = ExecuteString(engine, "main()", mod);
if( r != asEXECUTION_FINISHED )
TEST_FAILED;

engine->Release();
}


The test passed without any problems, so I'm obviously missing something.

Share this post


Link to post
Share on other sites
Yes, G_CallPain is a global function but I'm actually calling it as an object method there. Or even, I'm not calling it at all, but rather assign a pointer holding object's 'pain' funcdef property to it. After all, a function pointer is a function pointer, isn't it? ;)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!