Advertisement

Assert cause by "Make sure we found a destructor"

Started by November 29, 2004 11:05 AM
3 comments, last by abrken 19 years, 11 months ago
I'm working with 1.10.1 patched for backslash string. I was trying to play with arrays and an assert occurs. this is the script :

CString[] arCs(5000);
int i;
for (i = 0; i < arCs.length(); i++)
	arCs = CString("youkoulélé");
The assert occurs : as_bytecode.cpp line 570 on // Make sure we found a destructor assert( n < destructors.GetLength() ); I have tried to use without arrays and the assert also occurs !

CString arCs;
arCs = CString("youkoulélé");
So this is how CString is declared :

	in_pAsEngine->RegisterObjectType("CString", sizeof(string), asOBJ_CLASS);

	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONP(CString_Constructor, (CString &)), asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f(const bstr &)", asFUNCTIONP(CString_Constructor, (asBSTR &, CString &)), asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f(const string &)", asFUNCTIONP(CString_Constructor, (string &, CString &)), asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f(const bstr &, int)", asFUNCTIONP(CString_Constructor, (asBSTR &, int, CString &)), asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(CString_Destructor), asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ASSIGNMENT, "CString &f(const bstr &)", asFUNCTION(asCStringCopy),      asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ASSIGNMENT, "CString &f(const CString &)", asFUNCTION(asCStringCopyCString),      asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ASSIGNMENT, "CString &f(const string &)", asFUNCTION(asCStringCopyString),      asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ADD_ASSIGN, "CString &f(const bstr &)", asFUNCTION(asCStringAppend),    asCALL_CDECL_OBJLAST);
	in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ADD_ASSIGN, "CString &f(const CString &)", asFUNCTION(asCStringAppendCString),    asCALL_CDECL_OBJLAST);

	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_ADD,         "CString f(const CString &, const CString &)", asFUNCTION((CString(*)(const CString*,const CString*))asCStringConcatenate),        asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_ADD,         "CString f(const CString &, const bstr&)", asFUNCTION((CString(*)(const CString*,const asBSTR*))asCStringConcatenate),        asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_EQUAL,       "bool f(const CString &, const CString &)", asFUNCTION((bool(*)(const CString*,const CString*))asCStringEqual),              asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_EQUAL,       "bool f(const CString &, const bstr &)", asFUNCTION((bool(*)(const CString*,const asBSTR*))asCStringEqual),              asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL,    "bool f(const CString &, const CString &)", asFUNCTION(asCStringNotEqual),           asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN,    "bool f(const CString &, const CString &)", asFUNCTION(asCStringLessThan),           asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL,      "bool f(const CString &, const CString &)", asFUNCTION(asCStringLessThanOrEqual),    asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const CString &, const CString &)", asFUNCTION(asCStringGreaterThan),        asCALL_CDECL);
	in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL,      "bool f(const CString &, const CString &)", asFUNCTION(asCStringGreaterThanOrEqual), asCALL_CDECL);

Workaround :

CString arCs;
CString arCs2("youkoulélé");

arCs = arCs2;
Any idea ? Regards, AbrKen.
Looks like a bug in AS. I'll take a look at it during the day.

I was able to reproduce the problem with the following script:

CString("test");

Either it is the "test" string that doesn't get destroyed correctly, or it is the CString object.

It should NOT {I forgot the 'not' [wink]} take me too much time to actually locate the bug now. The question is when I will have the time [wink]. Hopefully it will be before the end of the day.

Regards,
Andreas

[Edited by - WitchLord on November 29, 2004 1:14:30 PM]

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
Quote: Original post by WitchLord
It should take me too much time to actually locate the bug now. The question is when I will have the time [wink]. Hopefully it will be before the end of the day.


No problem, there is a workaround.
Found the fix:

file: as_compiler.cpp
func: CompileFunctionCall()
line: 3655
descr: Add the following code inside the if( isConstructor ) {...} statement block.

if( isConstructor ){  ...  // Insert a destructor for the object  asSTypeBehaviour *beh = builder->GetBehaviour(&tempObj.dataType);  if( beh && beh->destruct )    bc->Destructor(BC_ADDDESTRSF, (asDWORD)beh->destruct, tempObj.stackOffset);}


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

That's fix the pb !

Thanks.

AbrKen.

This topic is closed to new replies.

Advertisement