Compiling angelscript on ppc64

Started by
43 comments, last by WitchLord 7 years, 8 months ago

returnVal is a member of the asCGeneric class. The value of returnVal is 0 before the call;

GetAddressOfReturnLocation is returning the address of the member returnVal.

*(asILockableSharedBool**)gen->GetAddressOfReturnLocation() = self->GetWeakRefFlag();

This statement sets value of returnVal to be the address to a asILockableSharedBool returned by GetWeakRefFlag().

I don't see anything wrong in that part of the code, and especially not something that wouldn't work on PPC64 but works on other machines.

Based on the callstack you showed in the earlier post I'm more inclined to think the address to the asCScriptObject in self is invalid. If the address is not pointing to a true asCScriptObject instance, the call to GetWeakRefFlag will fail with a segfault due to the lookup in the virtual function table giving an incorrect address. If I'm right in this suspicion the key to the solution is finding out how the address in self ended up pointing to an incorrect memory location.

Try printing the content of the asCScriptObject in self to see if the result appears to be normal. At the very least it should have a pointer to the objType that will give the name of the script class.

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

Based on the callstack you showed in the earlier post I'm more inclined to think the address to the asCScriptObject in self is invalid. If the address is not pointing to a true asCScriptObject instance, the call to GetWeakRefFlag will fail with a segfault due to the lookup in the virtual function table giving an incorrect address. If I'm right in this suspicion the key to the solution is finding out how the address in self ended up pointing to an incorrect memory location.

Try printing the content of the asCScriptObject in self to see if the result appears to be normal. At the very least it should have a pointer to the objType that will give the name of the script class.

You are right:

(gdb) p self

$7 = (asCScriptObject *) 0x10478870
(gdb) p *self
$8 = {<asIScriptObject> = {_vptr.asIScriptObject = 0x20}, objType = 0x371,
refCount = {value = 16383}, gcFlag = 1 '\001',
hasRefCountReachedZero = 0 '\000', isDestructCalled = 142,
extra = 0x3fffb78e1038 <main_arena+952>}
I'll keep looking for where things are going wrong.

Quick update: I solved the issue above. But now there is another issue when saving and loading back the bytecode. I'm looking into that now.

That's great news. Let me know if you need any help.

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

In the meantime, the attached patch adds initial support on angelscript for ppc64le (the little endian version of ppc64). All tests pass with AS_MAX_PORTABILITY defined.

P.S: had to append ".txt" to the patch file otherwise uploader wouldn't let me attach it.

Thanks. I've checked in this patch in revision 2255.

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

Andreas,

some progress update. My patch so far is attached.

* as of recent updates, I'm getting the following error on ppc64le:

-- TestEnumGlobVar passed
(0, 0) : Error : Failed in call to function 'RegisterGlobalFunction' with 'void Print(const string& in s)' (Code: -7)
(0, 0) : Error : Invalid configuration. Verify the registered application interface.
Failed on line 63 in ../../source/test_configaccess.cpp
--------------------------------------------
One of the tests failed, see details above.
* test_features pass on ppc64 up to test_addon_dictionary:
--- Assert failed ---
func: void main()
mdle: test
sect: test
line: 7
---------------------
Failed on line 119 in ../../source/test_addon_dictionary.cpp
--- Assert failed ---
func: void main()
mdle: test
sect: test
line: 4
---------------------
func: void main()
modl: test
sect: test
line: 4
desc: Assert failed
--- call stack ---
ExecuteString (1): void ExecuteString()
Failed on line 430 in ../../source/test_addon_dictionary.cpp
Test on line 531 in ../../source/test_addon_dictionary.cpp skipped
--------------------------------------------
One of the tests failed, see details above.
Any tips on how I can debug it? I tried registering a print function to check the value stored in the dictionary, but I was not able to (error similar to the one on ppc64le).


-- TestEnumGlobVar passed
(0, 0) : Error : Failed in call to function 'RegisterGlobalFunction' with 'void Print(const string& in s)' (Code: -7)
(0, 0) : Error : Invalid configuration. Verify the registered application interface.
Failed on line 63 in ../../source/test_configaccess.cpp
--------------------------------------------
One of the tests failed, see details above.

If all the tests up until TestConfigAccess::Test() in passed successfully I really don't understand why RegisterGlobalFunction at line 39 in test_configaccess.cpp would fail with asNOT_SUPPORTED (= -7). I suggest you debug the execution by stepping into that call to understand why it returns asNOT_SUPPORTED at that location.


* test_features pass on ppc64 up to test_addon_dictionary:

--- Assert failed ---
func: void main()
mdle: test
sect: test
line: 7

This assert failure is telling you that the script is not giving the proper result on line 7, i.e. on the following statement: "assert( int(dict['true']) == 1 );". Most likely it is the int() type conversion that is not working properly on big endian in the scriptdictionary.cpp code.

The script will call the registered ScriptDictionary_opConvInt function, which will indirectly call the method CScriptDictValue::Get(), passing in the typeId asTYPEID_INT64 as the wanted type. If the code works as I expect it, this will end up at line 751 in scriptdictionary.cpp where the actual type conversion is done with the following statement: "*(asINT64*)value = char(m_valueInt) ? 1 : 0;"

This is probably what is not working on the big endian PPC. It might be that a change in CScriptDictValue::Set() is needed too, to make sure the boolean type is stored correctly in the first place.


func: void main()
mdle: test
sect: test
line: 4

This second problem is failing on the script statement "assert( b == 1 );", which is translated to the following bytecode sequence:

- 4,5 -
0 21 * SUSPEND
1 21 * SetV1 v1, 0x1
3 21 * PshV4 v1
4 22 * CALLSYS 150 (void assert(bool))
You can find this in the debug output file AS_DEBUG/__main.txt right after compiling the script (if the library is compiled with the flag AS_DEBUG defined).
Most like the problem is with the bytecode instruction asBC_SetV1 in as_context.cpp, which is not setting the byte in the correct position of the target DWORD. A similar problem would exist with SetV2 as well.

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

I've applied your latest in-progress patch in revision 2270.

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


If all the tests up until TestConfigAccess::Test() in passed successfully I really don't understand why RegisterGlobalFunction at line 39 in test_configaccess.cpp would fail with asNOT_SUPPORTED (= -7). I suggest you debug the execution by stepping into that call to understand why it returns asNOT_SUPPORTED at that location.

It looks like the problem is that MAX_PORTABILITY is defined, so RegisterGlobalFunction returns NOT_SUPPORTED since the call is not registered as CALL_GENERIC.

This topic is closed to new replies.

Advertisement