segmentation fault


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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值