It has been my default assumption that I may have done something wrong. After a few days of looking into the issue I came at an impass that might need info from people who are more familiar.
The issue is failrly simple. I have a registered reference type, which in the script I am calling a method on. In c++ the code asserts as the pointer of the object is not correct. Below is the information I've gathered about the crash.
System: Mac Os X 10.8.2
IDE: Xcode 4
Achritecture: 64-bit
Compiler: Apple LLVM 4.2 (default) also occurs with (LLVM GCC 4.2)
Config: Appears in both Debug and Release builds
AngelScript: 2.26.1
- The issue appears to be related to functions which return a specific registered value type (Vector)
- Other method calls on the same object works fine
- Multiple object types suffer from this crash
- Occurs with both direct method calls and method wrapper functions
- The pointer to the object stored in angelcode is correct
- I have also tracked the object pointer up until the assebly code in x64_CallFunction code, and it appears to be fine until then
- The same codebase works fine on Windows VS2010. I'm currenting porting the code to OSX.
- I've attempted to re-create the issue with a new class value type and new methods, but those work fine.
- Issues also occurs if I use the "LLVM GCC 4.2" compiler
For reference, example configuration of the classes in question. (not full config) Again, this code works fine on the Windows side so I think the issue is deeper.
//This is the suspect value type
ret = engine->RegisterObjectType("Vector", sizeof(GtVector), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK); assert( ret >= 0 );
//Example of object method that fails
ret = engine->RegisterObjectType("Entity", 0, asOBJ_REF); assert( ret >= 0 );
ret = engine->RegisterObjectMethod("Entity", "Vector getOrigin()", asMETHOD(Entity, getOrigin), asCALL_THISCALL); assert( ret >= 0 );
//Another example of object method that fails
ret = engine->RegisterObjectType("Level", 0, asOBJ_REF | asOBJ_NOCOUNT); assert( ret >= 0 );
ret = engine->RegisterObjectMethod("Level", "Vector getBlockOrigin(const Vector& in)", asFUNCTION(_Level_getBlockOrigin), asCALL_CDECL_OBJFIRST); assert( ret >= 0 );
//Example of code that will break
Entity@ entity = CreateEntity("test"); //Works
entity.setOrigin(Vector(1,1,1)); //Works
Vector vector = entity.getOrigin(); //Fails: Entity::getOrigin() is called, but obj pointer is not right
At this point I believe the issue may deal with my compile configurations and/or the as_callfunc_x64_gcc.cpp. I'm not versed well in assembler however, so I'm kind of stuck on what to do. Any information anyone might be able to provide is welcomed. If there is more information I can provide about my issue please let me know.