Sign in to follow this  

Omitting frame pointer

This topic is 4415 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

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
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
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

This topic is 4415 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.

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