Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

segmentation fault while calling native functions with -O2


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 gdmarkou   Members   -  Reputation: 332

Like
0Likes
Like

Posted 20 December 2011 - 07:39 AM

I'm using gcc 4.6.1 under linux.
I've tried both the sdk from angelcode.com (2.22.0) and the latest revision (1080).

Without optimizations everything runs fine.

With optimizations (O1,2,3 doesn't matter) I recieve a segmentation fault from
CallCDeclFunction() in as_callfunc_x86.cpp
and this specific line :
"movl  12(%ebp), %eax \n"
(looking up the registers, both ebp and eax are 0)

The only solution I have (besides no optimization at all) is to build every file with -O2
and build as_callfunc_x86.cpp without optimizations, then link.

This way everything seems to work fine.

Other suggestions ?

Sponsor:

#2 Jeremy Harmon   Members   -  Reputation: 134

Like
0Likes
Like

Posted 20 December 2011 - 10:17 AM

Have you tried doing a full re-build? AngelScript has been tested with -O2 on the buildbot: http://angelscript.j...O2%29/builds/84

#3 Jeremy Harmon   Members   -  Reputation: 134

Like
0Likes
Like

Posted 20 December 2011 - 10:32 AM

I'm able to re-produce this problem on my machine using GCC 4.6.1. This bug is created by some change in GCC's optimization since v4.4.1 since that works with optimizations.

#4 gdmarkou   Members   -  Reputation: 332

Like
0Likes
Like

Posted 20 December 2011 - 10:47 AM

I'm able to re-produce this problem on my machine using GCC 4.6.1. This bug is created by some change in GCC's optimization since v4.4.1 since that works with optimizations.


So, this is one of the very rare cases that we should blame the compiler?
I feel so lucky... :)

By the way, i've tried some workarounds found on fourms around the web but nothing worked.
Like, changing the asm ("...") statement to asm volatile ("...") or asm __volatile__ ("...") did nothing.

Anyway, thanks for the reply.

#5 Jeremy Harmon   Members   -  Reputation: 134

Like
0Likes
Like

Posted 20 December 2011 - 11:05 AM

I'm going to set up a buildslave running GCC v4.6.1 with O2 optimizations, this should help Andreas track down the issue, and make sure it doesn't pop up again (at least with this version of gcc).

#6 Andreas Jonsson   Moderators   -  Reputation: 3444

Like
0Likes
Like

Posted 20 December 2011 - 05:48 PM

Thanks for the bug report.
I believe this has to do with the inline assembly in as_callfunc_x86.cpp not having the clobber lists. GNUC must have changed something in the way they optimized the code which probably makes it use some of the registers that is also used in the inline assembly.

I'll have the inline assembler updated to properly use clobber lists. Thanks Jeremy for setting up the buildbot.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#7 Andreas Jonsson   Moderators   -  Reputation: 3444

Like
0Likes
Like

Posted 02 January 2012 - 06:53 PM

Hi,

I've changed the inline assembler code in as_callfunc_x86.cpp to properly use clobber lists. Hopefully this has fixed the problem on gnuc 4.6.1. Do you mind giving it a try to confirm the fix? You can find the fix in revision 1094.

Unfortunately I couldn't confirm it with the buildbot that Jeremy set up yet. It seems it is not linking the test app correctly.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#8 gdmarkou   Members   -  Reputation: 332

Like
0Likes
Like

Posted 07 January 2012 - 03:05 PM

Hey, thanks. I can't check this right now, I will test it on Monday and post the results.

#9 Andreas Jonsson   Moderators   -  Reputation: 3444

Like
0Likes
Like

Posted 07 January 2012 - 03:24 PM

No problem. Actually, Jeremy gave me access to his machine and the previous changes didn't work as I had hoped. It seems to be a bug in gnuc after all, though it might just be me who don't know how the inline assembler works well enough.

Anyway, it wasn't too hard to figure out what gnuc was doing wrong and I've now changed the code to work around it. The final fix is in revision 1104.

Code has been confirmed to be working by Jeremy's buildbot.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#10 gdmarkou   Members   -  Reputation: 332

Like
0Likes
Like

Posted 09 January 2012 - 08:05 AM

Yes, it's working now. Thank you again.

#11 Andreas Jonsson   Moderators   -  Reputation: 3444

Like
0Likes
Like

Posted 09 January 2012 - 04:57 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS