Advertisement

Assert failures of unfreed temp variables?

Started by November 25, 2011 07:11 PM
3 comments, last by WitchLord 13 years ago
EDIT: rewrote whole post. What was there earlier was not actually the root cause of problems.

With current AngelScript SVN, I'm getting assert failures, when compiling scripts, either from tempVariables.GetLength() != 0, or the amount of variable allocations not matching free variables. Here's an example. The "node" handle is actually a global property, which will return non-null if the ScriptObject in question is attached to a scene node on the C++ side. It is also an auto handle.


class GameObject : ScriptObject
{
int health;

GameObject()
{
health = 10;
}

void Update(float deltaTime)
{
node.vars["Health"] = health; // This will cause unfreed temp variable of type Node@
}
}


Furthermore, some calls to C++ code that return an object handle (an auto handle, if that makes any difference) seem to now return null. This I can fix by putting back the first line in the code block below into asCCompiler::PerformFunctionCall(); the line was removed some time ago, as part of the fixes to the unsafe refs crash:


ctx->type.Set(descr->returnType); // this was removed

if( isConstructor )
{
// Sometimes the value types are allocated on the heap,
// which is when this way of constructing them is used.


Unfortunately I'm unable to construct a test easily, seems like the issue needs my full engine with the actual classes registered to manifest :(

In case they'll help, very abbreviated registrations of the (hopefully) relevant classes from the piece of code above: (some are same as in the unsafe ref crash)


engine->RegisterObjectType("String", sizeof(String), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterStringFactory("String", asFUNCTION(StringFactory), asCALL_CDECL);
engine->RegisterObjectType("Variant", sizeof(Variant), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(int)", asFUNCTION(ConstructVariantInt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(int)", asMETHODPR(Variant, operator =, (int), Variant&), asCALL_THISCALL);
engine->RegisterObjectType("VariantMap", sizeof(VariantMap), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterObjectMethod("VariantMap", "Variant& opIndex(const String&in)", asFUNCTION(VariantMapAt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectType("Node", 0, asOBJ_REF);
engine->RegisterObjectProperty("Node", "VariantMap vars", offsetof(Node, vars_));
engine->RegisterGlobalFunction("Node@+ get_node()", asFUNCTION(GetScriptContextNode), asCALL_CDECL);
I'll see if I can reproduce this problem.



You mentioned before the edit that you customize AngelScript. Are you seeing these problems even without the customization?

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
Unfortunately I'm not able to reproduce the problem.

I have implemented the exact same interface and script, yet there are no errors.



Anyway, I mind a small fix in the code that may possibly have been the cause. Please give revision 1061 a try.

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

Thank you very much! Now both the assert failures and the null return value problem are gone.

(When the asserts issue still existed, I found in the end that I did get them even without any modifications to AngelScript)
Thanks for the confirmation.

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