Advertisement

Mac OSX 10.4.11 (PPC) vs windows xp

Started by October 29, 2008 06:20 PM
3 comments, last by WitchLord 16 years, 1 month ago
i'm working on a cross-platform mud and i'm using angelscript as my scripting language right now i'm working on an mac ibook with os x 10.4.11 using xcode 2.5 as my ide and under windows xp 32bit i'm using mingw with codeblocks so under windows it works as i would expected it to but under osx the memory location that GetPlayer returns to the script for the cPlayer becomes corrupt after the completion of the running of the script below. is there any setting that i might of missed for osx that i should be aware of? i can provide more information if need be i'm not quite sure what else to put here i use the asIScriptEngine::scriptstring() method to do the testing of the script registering cBuffer and its script representation buffer are is my custom string class closer to a buffer because of how i use it and functions that i've attached to it script file

//test.as angelscript

int Send(buffer &name,buffer &message)
{
    cPlayer @Player;

    @Player = GetPlayer(name);

    Player.Send(message);
	
    return Player;
};


class decleration


class cPlayer
{
public:
	cPlayer();
	cPlayer(cPlayer &Player);
	~cPlayer();

	int Load(const char * FileName);
	int Save(const char * FileName);

	int Send(cBuffer & Message);

	void AddRef();
	void Release();

	int State;
	int SubState;

	cClient * Client;
	cBuffer FileName;
        cBuffer Name;

	cBuffer Password;

	int OLC;
	int Root;
	int Admin;

        int ID;

	int refCount;
private:
};

[\source]

class registration for engine



int RegisterPlayer(asIScriptEngine * Engine)
{
    int r;

    r = Engine->RegisterObjectType("cPlayer", sizeof(cPlayer),asOBJ_REF); assert(r >= 0);
    r = Engine->RegisterObjectBehaviour("cPlayer", asBEHAVE_ADDREF,"void f()" , asMETHOD(cPlayer,AddRef), asCALL_THISCALL); assert(r >= 0);
    r = Engine->RegisterObjectBehaviour("cPlayer", asBEHAVE_RELEASE,"void f()" , asMETHOD(cPlayer,Release), asCALL_THISCALL); assert(r >= 0);

    r = Engine->RegisterObjectMethod("cPlayer", "int Send(buffer &in)", asMETHODPR(cPlayer,Send,(cBuffer&),int), asCALL_THISCALL); assert(r >= 0);

    r = Engine->RegisterObjectProperty("cPlayer" , "buffer Name" , offsetof(cPlayer,Name)); assert(r >= 0);
    r = Engine->RegisterObjectProperty("cPlayer" , "int ID", offsetof(cPlayer,ID)); assert(r >= 0);
    r = Engine->RegisterObjectProperty("cPlayer" , "int State", offsetof(cPlayer,State)); assert(r >= 0);
    r = Engine->RegisterObjectProperty("cPlayer" , "int SubState",offsetof(cPlayer,SubState)); assert(r>= 0);

    r=Engine->RegisterGlobalFunction("cPlayer @ GetPlayer(buffer&)",asFUNCTION(GetPlayer),asCALL_CDECL); assert( r >= 0 );

    return 1;
}

[\source]
0))))))>|FritzMar>
I'll do some tests on my MacMini to see if I can reproduce your problem.

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

Advertisement
Can you answer a few questions so that I can get a better picture of what's going on?

Is the GetPlayer returning the proper handle?

Are you calling AddRef on the pointer that GetPlayer returns? AngelScript will call Release on the pointer it received afterwards. So if your application still keeps a copy of it you must call AddRef on it, or your application will end up with an invalid pointer.

Is the this pointer correct in the Send(message) call? Is the memory corrupt at this moment?

Your script is declared to return an int, yet the script is returning the player. I assume this is a typo, but could you confirm what is correct?



Yesterday I tested the library on Mac OS X (both for x86 and ppc) and added support for multithreading. I don't think this is related to your problem, but you might be interested in picking up the latest version from the SVN anyway.

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

GetPlayer will return null if i provide an invalid player name, runnning the function outside of the script i recv valid player pointers, and inside of the script the handle stays valid until after Player.Send() in my testing i have a print command that prints out Player.Name so the memory is valid at least until
my last call to Player from with in the script. the return of the player handle is a typo left from when i was testing to see if returning the handle and placing it outside of the scope of my send function would fix my issue.

i'll see if i can come up with an isolated version of the error with out the rest of my code bloating it

while probaly not proper reference counting all my AddRef does is change the value of refCount to a value 1 and Release changes refCount to a value of 0
0))))))>|FritzMar>
If your reference counters doesn't actually do anything, then we can at least rule out that the memory is getting freed too early. However, that makes this a bug in AngelScript, and one that is probably isolated to the Mac PPC platform.

I'd appreciate the isolated test case. It will make it easier for me to detect and fix the bug.

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