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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章