Like Tree2Likes
  • 1 Post By Salem
  • 1 Post By iMalc

i have doubt

This is a discussion on i have doubt within the C Programming forums, part of the General Programming Boards category; during the compilation of program i got an error called "segmentation fault"....... what does it mean????? how should i clear ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    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.
    whiteflags likes this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    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.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  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,296
    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.
    AndrewHunter likes this.
    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, 02: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, 09:32 AM
  5. Doubt!!!
    By aqua in forum C Programming
    Replies: 2
    Last Post: 01-10-2003, 02:13 AM

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