Thread: i have doubt

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Question i have doubt

    during the compilation of program i got an error called "segmentation fault".......
    what does it mean?????
    how should i clear this problem............

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    First, it is "I have a question", not "I have doubt"

    Second, you need to be clear about which step the segfault happens.

    A segfault during actual compilation is very rare, and indicates a bug in the compiler.

    Mostly, segfaults arise when you run your code.

    Eg.
    Code:
    $ cat foo.c
    #include <stdio.h>
    int main ( ) {
      int *p = NULL;
      *p = 0;       // deliberate segfault
      return 0;
    }
    $ gcc foo.c
    $ ./a.out 
    Segmentation fault
    We would need to see your code, if you're running your code, and it crashes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    That means you have tried to access some memory your program doesn't own.

    how should i clear this problem........................................... ......................
    By magic, unless you provide more details .

    Also..segmentation Faults happen during runtime , not during compilation..(unless you are using a prehistoric compiler)

    [/]Sorry.. Noticed Salem's post after posting this.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by krishnaswathi View Post
    during the compilation of program i got an error called "segmentation fault".......
    It means you broke your compiler!?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by krishnaswathi View Post
    during the compilation of program i got an error called "segmentation fault".......
    Highly doubtful that it was during compilation.
    what does it mean?????
    It means that there is a bug where memory was attempted to be read or written from an invalid address.
    how should i clear this problem............
    Fix the bug.

    Learn to write properly. Sentences start with a capital letter and end in a single dot, question mark, or exclamation mark. If you don't make the effort to write properly then I wont make the effort to answer your questions properly. The word "I" is always capitalised.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Quote Originally Posted by iMalc View Post
    It means that there is a bug where memory was attempted to be read or written from an invalid address.
    Slightly off topic but I'm curious:
    Would 'execute' also cause a segfault assuming a kernel and cpu which supports DEP? Or is that a separate signal? I don't have much experience with linux/unix but I know on windows they are all under the same exception code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doubt
    By sureshsuresh528 in forum C Programming
    Replies: 3
    Last Post: 02-01-2008, 03:00 AM
  2. doubt...
    By anntenna333 in forum C Programming
    Replies: 4
    Last Post: 04-27-2006, 11:35 AM
  3. doubt
    By spveer in forum C Programming
    Replies: 3
    Last Post: 08-15-2005, 02:23 AM
  4. When in doubt, run away
    By Zach L. in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-07-2004, 10:32 AM
  5. Doubt!!!
    By aqua in forum C Programming
    Replies: 2
    Last Post: 01-10-2003, 03:13 AM