1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fedora 9: Receiving "Segmentation fault" in running C/C++ codes,

Discussion in 'Programming' started by ehsan, Nov 10, 2008.

  1. ehsan

    ehsan New Member

    Nov 10, 2008
    Likes Received:
    Trophy Points:

    Previously I was writing C/C++ codes in windows. Recently when I started to write codes under Fedora 9, I am getting a problem. The problem is that most of the times when I run my program, after compiling with GNU g++, it gives "Segmentation Fault" error. I looked around in books searching for the roots of this error. In a book, the writer told that this error error arises if we open too many files at the same time. But in my code I am not even opening or writing even to a single file.
    I tried my best but still I am not able to debug this error. Can any humane expert out there help me out in this regard. I would really appreciate his/her effort.

    Ehsan ul haq
  2. xpi0t0s

    xpi0t0s Mentor

    Aug 6, 2004
    Likes Received:
    Trophy Points:
    Senior Support Engineer
    A segfault has nothing to do with opening files; it means you've accessed memory you haven't allocated, or tried to write to an area of memory where you shouldn't. You need to look carefully at the code that is segfaulting - get a stack trace from the debugger, and see what your code is doing at the exact point the segfault happens, and try to think about how that line of code could be accessing wrong memory. Hint: "It can't, because the same code works on Windows" is not a good place to start. "It is" is far better.

Share This Page