Segmentation fault 段错误

A segmentation fault (often shortened to segfault) or bus error is generally an attempt to access memory that the CPU cannot physically address. It occurs when the hardware notifies a Unix-like operating system about a memory access violation. Then the OS kernel sends a signal to the process which caused the exception. By default the process receiving the signal dumps core and terminates. The default signal handler can also be overridden to customize how the signal is handled.[1]

 

Common causes

A few causes of a segmentation fault can be summarized as follows:

  • attempting to execute a program that does not compile correctly. Note that most compilers will not output a binary given a compile-time error.
  • a buffer overflow.
  • using uninitialized pointers.
  • dereferencing NULL pointers.
  • attempting to access memory the program does not own.
  • attempting to alter memory the program does not own (storage violation).

 

from:

http://en.wikipedia.org/wiki/Segmentation_fault

你可能感兴趣的:(IO)