Sign in to follow this  
DaBono

Omitting frame pointer

Recommended Posts

DaBono    1496
In the release builds of my program I give gcc the -fomit-frame-pointer option. However, lately I noticed that - whenever an exception is thrown - I get a segmentation fault. The gcc man-page says about this option that it omits the frame pointer '...for functions that don’t need one.', which sounds pretty safe to me. When I compile without the option (but with -momit-leaf-frame-pointer) everything works fine. Could someone explain this behaviour to me? Is my code broken, or am I doing something I shouldn't?

Share this post


Link to post
Share on other sites
Cocalus    554
Are you also passing -fexceptions (I think that's right command) to gcc. by default it doesn't use execption handling (that may be different with some newer versions). So you have to enable it.

Share this post


Link to post
Share on other sites
DaBono    1496
I'm using gcc 4.0.1, which now indeed has exception handling on by default. I tried to specify -fexceptions specifically, but als to no avail.
Thanks for the suggestion, though.

Share this post


Link to post
Share on other sites
LessBread    1415
Assuming an x86 cpu, my guess is that the exception frame is built in a way that assumes the presence of a stack frame. So when the stack frame is omitted and an exception occurs, you get another exception when the exception handler for the first exception attempts to reference a non existent stack frame and the exception inside the exception begats the seg fault. Are you running Windows?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this