Jump to content
  • Advertisement
Sign in to follow this  
rviney

Crash calling global function on 64-bit Mac OS X

This topic is 2550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I'm pretty new to AngelScript and I've run into a problem with a 64-bit build on Mac OS X 10.7. I'm using the latest Xcode 4.2 tools (GCC 4.2.1, Clang 3.0).

The first problem is that a 64-bit build of AngelScript 2.22.0 isn't possible under Clang, the 32-bit build is fine though. The specific error it gives is:


$ clang++ -c -arch x86_64 source/as_callfunc_x64_gcc.cpp
fatal error: error in backend: Inline asm clobbers must be last on the x87 stack


You can get around this easily enough by using GCC instead of Clang. You can also make the error go away by commenting out the 'retval = call();' line in X64_CallFunction() but that obviously makes the whole thing non-functional!

[hr]
The second problem is that, having switched from Clang to GCC, enabling any optimizations at all triggers crashes when calling a simple global function:


static void foo() { printf("foo()\n"); }
...
engine->RegisterGlobalFunction("void foo()", asFUNCTION(foo), asCALL_CDECL);


The script I'm running is:



void main()
{
foo();
}


The crash is inside CallSystemFunctionNative() in as_callfunc_x64_gcc.cpp. Building 64-bit AngelScript under GCC with no optimizations gets rid of the crash, as does switching to a 32-bit build.

Any insight on the above two issues would be much appreciated.

Thanks,
Richard

Share this post


Link to post
Share on other sites
Advertisement
Unfortunately I don't know anything about Clang, so I can't help you on those questions.

As for the crash with gcc, it sounds a lot like the problem that was fixed in version 2.22.0. I got confirmation from another developer that also use Mac OS X 64bit that it was working properly. I guess you're using a sligthly different configuration than he do.

Unfortunately I do not have a Mac OS X 64bit environment to make any tests or debugging, so I hope you can do a little indepth investigation on your own to find the problem. The problem is most likely with the inline assembly since you say it works without the optimizations. The GCC optimizations must be making some assumptions that are not true with the inline assembly that I have in as_callfunc_x64_gcc.cpp. I'm probably overwriting some register that the optimizer used to store some value, or maybe the alignment of the stack is not the same on Mac OS X 64bit as it is on Linux 64bit.

Regards,
Andreas

Share this post


Link to post
Share on other sites
The crash you were facing on Mac OS X 64bit has probably been fixed now. I've made a fix with the help from dutt who was also facing a crash on Mac OS X 64bit. Please give revision 1069 a try and see if it works for you too.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Both the original issues are fixed in the latest revision, thanks! The Clang build is working nicely.

Regards,
Richard

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!