Sign in to follow this  
dxj19831029

complex assert break, bug??

Recommended Posts

The script version is the newest one, I check out today. The assert failed line is at: as_compiler.cpp, line: 498 I don't have compile errors. The actual class registeration is very complicate, I believe the bug is this, if not, let me know, I will try to reproduce it with a simple version of code.
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A", asBEHAVE_INDEX , "Value &f(int)", asMETHODPR(A, operator[], (int ), Value &), asCALL_THISCALL); 
assert( nRet >= 0 );

nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[]", asBEHAVE_INDEX , "A f( int )", asMETHODPR(AArray, operator[], (int ), A), asCALL_THISCALL); 
assert( nRet >= 0 );


nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[][]", asBEHAVE_INDEX , "A[] f(int)", asMETHODPR(AArrayArray, operator[], (int ), AArray), asCALL_THISCALL); 
assert( nRet >= 0 );

All the class A, AArray, AArrayArray are registerred as asOBJ_VALUE | asOBJ_APP_CLASS_CDA. The registeration without any error. The build on the script which use sentence:
 
A[][] twoD; twoD[1][1][1] = "abcd";
I am not sure if this sentence got error, but the build on the script failed on the above position.. If I register as:
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A", asBEHAVE_INDEX , "Value &f(int)", asMETHODPR(A, operator[], (int ), Value &), asCALL_THISCALL); 
assert( nRet >= 0 );

nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[]", asBEHAVE_INDEX , "A &f( int )", asMETHODPR(AArray, operator[], (int ), A), asCALL_THISCALL); 
assert( nRet >= 0 );


nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[][]", asBEHAVE_INDEX , "A[] f(int)", asMETHODPR(AArrayArray, operator[], (int ), AArray), asCALL_THISCALL); 
assert( nRet >= 0 );
The build error is gone. The only difference is to return a reference on A[] index or on A[][] index. Any ideas?

Share this post


Link to post
Share on other sites
Assert failures within the script engine is always due to some bug. Though usually the bug is not critical and caused by the compiler incorrectly trying to proceed with the compilation after a compler error.

If you can reproduce the problem with a smaller program I would be very thankful, as it will greatly help me in locating and fixing the bug.

Share this post


Link to post
Share on other sites
:) I just got back from holiday.

Here is the simple version of code to reproduce the problem.

class Value {
public:
Value() {
a = 4;
}
int a;
};
static Value v_static;
class A {
public:
Value &operator[] (int n) {
return v_static;
}
};
class AArray {
public:
A operator[] (int n) {
return A();
}
};
class AArrayArray {
public:
AArray operator[] (int n) {
return AArray();
}
};
int scriptTestClasses() {
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("Value", sizeof(Value), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );

nRet = (asERetCodes) pScriptEngine->RegisterObjectType("A", sizeof(A), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A", asBEHAVE_INDEX , "Value &f(int)", asMETHODPR(A, operator[], (int ), Value &), asCALL_THISCALL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("A[]", sizeof(AArray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[]", asBEHAVE_INDEX , "A f( int )", asMETHODPR(AArray, operator[], (int ), A), asCALL_THISCALL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("A[][]", sizeof(AArrayArray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[][]", asBEHAVE_INDEX , "A[] f(int)", asMETHODPR(AArrayArray, operator[], (int ), AArray), asCALL_THISCALL);
assert( nRet >= 0 );

nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f;", NULL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; f[0];", NULL);
assert( nRet >= 0 );
// Bug appear in the following line.
nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; f[0][0];", NULL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; print(f[0][0][0]);", NULL);
assert( nRet >= 0 );
return 0;
}



Hope this will help u. The bug will appear in the line:

nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; f[0][0];", NULL);

when building this script code, I think.

Thanks.

Quote:
Original post by WitchLord
Assert failures within the script engine is always due to some bug. Though usually the bug is not critical and caused by the compiler incorrectly trying to proceed with the compilation after a compler error.

If you can reproduce the problem with a smaller program I would be very thankful, as it will greatly help me in locating and fixing the bug.

Share this post


Link to post
Share on other sites
Did the code regenerate the error?

I am thinking, should you write a simple instruction for us to follow to write the test case for you? in that case, you can simple plug into testing engine and test? I think the files in the test_feature is a good example.

or even better, you can open a short directory in the svn, we could have permission to upload small piece of code to that directory, or something like that.

I think this will provide a good interface for us to contribute to test angelscript and help you to fix the bug.

What do you think?

Quote:
Original post by dxj19831029
:) I just got back from holiday.

Here is the simple version of code to reproduce the problem.

class Value {
public:
Value() {
a = 4;
}
int a;
};
static Value v_static;
class A {
public:
Value &operator[] (int n) {
return v_static;
}
};
class AArray {
public:
A operator[] (int n) {
return A();
}
};
class AArrayArray {
public:
AArray operator[] (int n) {
return AArray();
}
};
int scriptTestClasses() {
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("Value", sizeof(Value), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );

nRet = (asERetCodes) pScriptEngine->RegisterObjectType("A", sizeof(A), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A", asBEHAVE_INDEX , "Value &f(int)", asMETHODPR(A, operator[], (int ), Value &), asCALL_THISCALL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("A[]", sizeof(AArray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[]", asBEHAVE_INDEX , "A f( int )", asMETHODPR(AArray, operator[], (int ), A), asCALL_THISCALL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("A[][]", sizeof(AArrayArray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectBehaviour("A[][]", asBEHAVE_INDEX , "A[] f(int)", asMETHODPR(AArrayArray, operator[], (int ), AArray), asCALL_THISCALL);
assert( nRet >= 0 );

nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f;", NULL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; f[0];", NULL);
assert( nRet >= 0 );
// Bug appear in the following line.
nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; f[0][0];", NULL);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; print(f[0][0][0]);", NULL);
assert( nRet >= 0 );
return 0;
}



Hope this will help u. The bug will appear in the line:

nRet = (asERetCodes) pScriptEngine->ExecuteString(NULL, "A[][] f; f[0][0];", NULL);

when building this script code, I think.

Thanks.

Quote:
Original post by WitchLord
Assert failures within the script engine is always due to some bug. Though usually the bug is not critical and caused by the compiler incorrectly trying to proceed with the compilation after a compler error.

If you can reproduce the problem with a smaller program I would be very thankful, as it will greatly help me in locating and fixing the bug.


Share this post


Link to post
Share on other sites
I haven't had the time to look into this problem yet. I'm planning to do so this weekend.

The only instructions I have for creating test cases is to try to reduce as much of the engine configuration and scripts that don't impact the test itself. Basing the tests on the ones in test_feature is a good idea, but not always necessary.

There's no need for you guys to write/upload the test cases for me. Just help me come up with a small enough test case and I'll add it to the test_feature project myself. You may continue to post your tests here on the forum.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Ok. Cool. :)
Quote:
Original post by WitchLord
I haven't had the time to look into this problem yet. I'm planning to do so this weekend.

The only instructions I have for creating test cases is to try to reduce as much of the engine configuration and scripts that don't impact the test itself. Basing the tests on the ones in test_feature is a good idea, but not always necessary.

There's no need for you guys to write/upload the test cases for me. Just help me come up with a small enough test case and I'll add it to the test_feature project myself. You may continue to post your tests here on the forum.

Regards,
Andreas


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this