Omitting frame pointer

Started by
3 comments, last by LessBread 18 years, 5 months ago
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?
Advertisement
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.
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.
Does it crash with a simple test program? Does the optimization flag affect its crashing (or what flags are you passing it)?
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?
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement