Internet FAQ Archives

...definition of "Segmentation Fault" - Where is...

Internet RFC Index

Usenet FAQ Index

Other FAQs

Documents

Search
  Search FAQs

 

 

[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


 

Question by SLayne
Submitted on 7/10/2003
Related FAQ: comp.unix.aix Frequently Asked Questions (Part 1 of 5)
Rating: Rate this question: Vote
What is the definition of "Segmentation Fault" - Where is this defined?

 
 

Answer by David
Submitted on 7/16/2003
Rating:  Rate this answer: Vote
Segmentation Fault occurred when running c program that is reading or writing non-exist segment(physical memory space). Example, declare an array of int x[5] and you try putting or reading 6th item(s) that the cpu system to crash.

 

Answer by Dragon Dave
Submitted on 8/25/2003
Rating:  Rate this answer: Vote
It can be a sporadic occurance; for example, in the program below, if you type 'Dragon' it works quite happily. It's overwriting some part of the memory with something it shouldn't be. But it doesn't segfault until you get to something like 'Dragon Dave is overwriting your memory!'. This is a buffer overrun, and that's *bad*, and a very, very large hole in your programs security.

#include "stdio.h"
int main()
{
/* allocate 5 bytes for the string */
   char name[5];
/* enter a string - possibly much longer */
   gets(name);
/* display the string */
   printf("Hello, %s.",name);
}

 

Answer by kon
Submitted on 10/22/2003
Rating:  Rate this answer: Vote
segmentation faults may also occur in case of hardware errors, f.e. hard-disk or Memory failure. to find out, try running memtest86 and/or any hard-disk diagnostic tools from the manufacturer

 

Answer by prashant
Submitted on 11/4/2003
Rating:  Rate this answer: Vote
segmentation fault is a type of error which occurs when u try to access a non existant physical memory address. Sometimes during execution of a C program u freed  memory and then within the scope of the same program try again to use the same memory, then also the seg. fault occurs, this is due to the fact that untill the completion of the program the memory utilised is not returned to the operating system.

 

Answer by Liang Yu
Submitted on 12/11/2003
Rating:  Rate this answer: Vote
This is often caused by improper usage of pointers in the source code, dereferencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

 

Answer by Ryan
Submitted on 1/18/2004
Rating:  Rate this answer: Vote
Segmentation fault is a bad error.

 

Answer by ashwin
Submitted on 2/14/2004
Rating:  Rate this answer: Vote
if u allot some memory for array in the beginning of the programme and if u try to store the more numbers in the array and if it requires more memory that that has been allocated then it will result in segmentation fault  

 

Answer by kilgroja
Submitted on 3/26/2004
Rating:  Rate this answer: Vote
Ok. I understand. But...what about this:
void *memPtr = malloc(25);  //causes coredump

But, if I change the statement to:
void *memPtr = malloc(24);  //ok

Anything > 24 in this particular program causes a coredump. My debugger (ladebug) tells me that I got a signal segmentation fault. The system I'm running on is a Compaq Tru64 system with oodles of memory. I can port it to another Tru64 system and the same thing happens.

Can anyone give me a clue what might be happening?

 

Answer by logicTRANCE
Submitted on 4/17/2004
Rating:  Rate this answer: Vote
did you check on other machines? other than Compaq Tru64....
if it runs properly on other machines, report compaq call centre or equivalent...it must be a bug....

also, if you are using C++, try using
void *memPtr = new(24);

i've never tried it..but i think it should work...
goodluck!
Happy Programming!

 

Answer by Nothix
Submitted on 4/26/2004
Rating:  Rate this answer: Vote
Thanks for the pointer Tip!

 

Answer by bt
Submitted on 5/4/2004
Rating:  Rate this answer: Vote
get as point please

 

Answer by anand
Submitted on 6/19/2004
Rating: Not yet rated Rate this answer: Vote
This is often caused by improper usage of pointers in the source code, dereferencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: comp.unix.aix Frequently Asked Questions (Part 1 of 5)

 

© 2003 FAQS.ORG.  All rights reserved.