64-bit issues with a string class

Started by
11 comments, last by WitchLord 14 years ago
Sorry for taking so long to look into this. I made another attempt to reproduce this problem with your latest information, but unfortunately I'm still not able to. This is the code I wrote to test the scenario:

enum TEST_ENUM{	ENUM1 = 1,	ENUM2 = ENUM1*10,	ENUM3,	ENUM4 = -1};class CTestObject{public:	bool TestEnum(TEST_ENUM e) { val = e; if( e == ENUM2 ) return true; else return false; }	TEST_ENUM val;};bool Test(){	asIScriptEngine   *engine;	CBufferedOutStream bout;	int                r;	bool               fail = false; 	engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);	bout.buffer = "";	r = engine->SetMessageCallback(asMETHOD(CBufferedOutStream,Callback), &bout, asCALL_THISCALL);	r = engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC);	// Register the enum value	r = engine->RegisterEnum("TEST_ENUM"); assert(r >= 0);	r = engine->RegisterEnumValue("TEST_ENUM", "ENUM1", ENUM1); assert(r >= 0);	r = engine->RegisterEnumValue("TEST_ENUM", "ENUM2", ENUM2); assert(r >= 0);	r = engine->RegisterEnumValue("TEST_ENUM", "ENUM3", ENUM3); assert(r >= 0);	// Test enum in param to class method	assert( sizeof(TEST_ENUM) == 4 );	r = engine->RegisterObjectType("Obj", 0, asOBJ_REF | asOBJ_NOHANDLE); assert( r >= 0 );	r = engine->RegisterObjectMethod("Obj", "bool TestEnum(TEST_ENUM)", asMETHOD(CTestObject, TestEnum), asCALL_THISCALL); assert( r >= 0 );		CTestObject obj;	obj.val = ENUM1;	r = engine->RegisterGlobalProperty("Obj obj", &obj); assert( r >= 0 );	bout.buffer = "";	r = ExecuteString(engine, "if( !obj.TestEnum(ENUM2) ) assert(false); ");	if( r != asEXECUTION_FINISHED )		fail = true;	if( bout.buffer != "" )	{		printf(bout.buffer.c_str());		fail = true;	}	if( obj.val != ENUM2 )		fail = true;	engine->Release();	return fail;}


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
Here is an example I made on 64-bit Linux:
http://suckerfreegames.com/_as/as_bug.zip

I used the projects/gnuc/makefile to compile AngelScript. I then compiled my example with:
g++ main.cpp scriptstdstring.cpp -langelscript

The program will generate a segmentation fault and crash.

I added two versions of the problem function. If you switch the comment to the first line, you can see that the enum-to-int conversion workaround doesn't cause a crash:
r = engine->RegisterGlobalFunction("bool TestEnum(TEST_ENUM)", asFUNCTION(TestEnum), asCALL_CDECL); assert(r >= 0);//r = engine->RegisterGlobalFunction("bool TestEnum(int)", asFUNCTION(TestEnum2), asCALL_CDECL); assert(r >= 0);
That did the trick. Thanks a lot for the help in reproducing the problem.

I've now fixed this bug in revision 576.

Diff for as_datatype.cpp

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