Segmentation Fault
2007-06-02 00:47
274 查看
An error in which a running Unix program attempts to access memory not allocated to it and terminates with a segmentation violation error and usually a core dump.
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.
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);
}
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
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.
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.
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.
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);
}
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
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.
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.
相关文章推荐
- segmentation fault mac xvid ffmpeg
- linux线程(pthread)编程中的segmentation fault!!
- Segmentation Fault in Linux(3.如何避免SIGSEGV)
- 关于linux的段错误(Segmentation fault)
- crosstool-ng Patch glibc to fix busybox causing "segmentation fault".
- About Segmentation Fault in Linux ( SIGSEGV )
- 【转载】段错误总结(segmentation fault)
- Program received signal SIGSEGV, Segmentation fault.
- 3_14_2(Segmentation_fault_3)
- C/C++中的段错误(Segmentation fault)[转]
- 编译qt/embedded应用程序时出现的segmentation fault 问题解决办法
- 几种段错误(segmentation fault) 实例
- Segmentation fault in c program runtime
- ZOJ 1298 Domino Effect 遗憾之Segmentation Fault
- linux segmentation fault记录
- [web服务器]APACHE日志child pid XXXXXX exit signal Segmentation fault (11)解决
- "zend_mm_heap corrupted"、"Segmentation fault"问题
- 关于Segmentation fault的问题
- Segmentation Fault in Linux 原因与避免
- Linux Segmentation Fault 段错误 产生原因调试方法