# Linux 段错误类型
There are three kinds of SEGV, which is an error that results from an invalid memory access:
1. A page was accessed which had the wrong permissions. E.g., it was read-only but your code tried to write to it. This will be reported as `SEGV_ACCERR`.
2. A page was accessed that is not even mapped into the address space of the application at all. This will often result from dereferencing a null pointer or a pointer that was corrupted with a small integer value. This is reported as `SEGV_MAPERR`.
3. A new SEGV error code `SEGV_BNDERR` is introduced in new kernel.
可以参考 Linux kernel 源代码中的 `include/uapi/asm-generic/siginfo.h` 文件:
```h
/*
* SIGSEGV si_codes
*/
#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */
#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */
#define SEGV_BNDERR (__SI_FAULT|3) /* failed address bound checks */
#define NSIGSEGV 3
```