Flag -fomit-frame-pointer cause seg fault

This is a discussion on Flag -fomit-frame-pointer cause seg fault within the C++ Programming forums, part of the General Programming Boards category; Hi All, I am running a code under g++, which has been running fine with the flags: Code: CXXFLAGS= -O3 ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    7

    Flag -fomit-frame-pointer cause seg fault

    Hi All,
    I am running a code under g++, which has been running fine with the flags:
    Code:
    CXXFLAGS= -O3 -funroll-all-loops -ffast-math
    But as I add -fomit-frame-pointer to get:
    Code:
    CXXFLAGS= -O3 -funroll-all-loops -fomit-frame-pointer -ffast-math
    then the program gives a segmentation fault. Unfortunately this flag also removes the trace so I don't know how to track it.

    Any ideas?

    Thanks,
    Dave

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    7
    Aftersome searching it seems the problem may be to do with the fact that I am running on Cygwin.

    See:
    http://cygwin.com/ml/cygwin/2001-04/msg01914.html

    If anyone knows how to work around it I would be grateful.

    D

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The post is 6 years old. I think it's a fair assumption that the bug is corrected. What is more likely is that you have some undefined behaviour that is uncovered by omitting the frame pointer.

    First, see if the problem still occurs if you remove all optimization flags but omit-frame-pointer. Then, add -g to the minimal set of flags that show the problem and see if it persists. If it does, run the program under gdb and get a stack trace.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,269
    Quote Originally Posted by CornedBee View Post
    First, see if the problem still occurs if you remove all optimization flags but omit-frame-pointer. Then, add -g to the minimal set of flags that show the problem and see if it persists. If it does, run the program under gdb and get a stack trace.
    -fomit-frame-pointer == no stack trace

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    My GCC disagrees. Might be different for MinGW.

    Code:
    void f();
    void g();
    void h();
    void i();
    
    int main()
    {
      f();
      return 0;
    }
    
    void f() { g(); }
    void g() { h(); }
    void h() { i(); }
    
    void i()
    {
      int *p = 0;
      *p = 1;
    }
    Code:
    $ cc -fomit-frame-pointer -o trace trace.c
    $ gdb trace
    (gdb) run
    Starting program: /home/wasti/projects/test/trace
    
    Program received signal SIGSEGV, Segmentation fault.
    0x00000000004004f7 in i ()
    (gdb) bt
    #0  0x00000000004004f7 in i ()
    #1  0x00000000004004e4 in h ()
    #2  0x00000000004004d1 in g ()
    #3  0x00000000004004be in f ()
    #4  0x00000000004004a6 in main ()
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-15-2008, 10:24 AM
  2. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 02:17 PM
  3. seg fault
    By hka26 in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2007, 02:38 AM
  4. Seg Fault Problem
    By ChazWest in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2002, 04:24 PM
  5. seg fault on unix platform
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 12-08-2001, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21