Advertisement

Assertion failure in as_configgroup.cpp

Started by January 21, 2012 11:36 AM
24 comments, last by _Vicious_ 12 years, 10 months ago
Hello Andreas,

I hit the following assertion failure upon config group shutdown (v 2.2.2): http://www.foopics.c...844c3d87c9d3257
It seems to be related to string factory method/function somehow. What this assertion failure might indicate?
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

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

Advertisement
Basically, it happens upon each time I close the app in Debug mode. No special steps are required..
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?

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

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
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

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

Advertisement
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.
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.

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

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.

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

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? ;)

This topic is closed to new replies.

Advertisement