1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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

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

  1. ehsan

    ehsan New Member

    Joined:
    Nov 10, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    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.

    Regards,
    Ehsan ul haq
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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