关闭

segmentation fault

693人阅读 评论(0) 收藏 举报
分类:


Segmentation fault
段错误
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).
当程序试图访问不允许被访问的内存位置,或试图以未授权的方式访问内存位置时(例如,试图写只读内存位置,或试图修改操作系统部分),就会发生段错误。


Common causes
常见的原因
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following are some typical causes of a segmentation fault:
造成段错误的几种典型的原因:

Attempting to execute a program that does not compile correctly. Some compilers will output an executable file despite the presence of compile-time errors
试图执行未正确编译的程序。某些编译器会不顾编译时错误继续暑促可执行文件。

Dereferencing NULL pointers
解引用空指针

Attempting to access memory the program does not have rights to (such as kernel structures in process context)
试图访问程序无权访问的内存

Attempting to access a nonexistent memory address (outside process's address space)
试图访问不存在的内存地址

Attempting to write read-only memory (such as code segment)
试图写只读内存

A buffer overflow
缓冲区溢出

Using uninitialized pointers
使用未初始化的指针

Generally, segmentation faults occur because a pointer is NULL, or because it points to random memory (probably never initialized to anything), or because it points to memory that has been freed/deallocated/"deleted".
通常,段错误的原因为指针为空,或指向随机内存,或因为指向已释放已被解除分配、或已被删除的内存


pasted from wikipedia


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:47648次
    • 积分:744
    • 等级:
    • 排名:千里之外
    • 原创:19篇
    • 转载:23篇
    • 译文:2篇
    • 评论:3条
    牛博链接
    文章分类