Linux 什么是 SEGV_MAPERR?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1000002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is SEGV_MAPERR?
提问by Geek
What is SEGV_MAPERR
, why does it always come up with SIGSEGV
?
是什么SEGV_MAPERR
,为什么老是想出来SIGSEGV
?
采纳答案by ahcox
There are two common kinds of SEGV, which is an error that results from an invalid memory access:
有两种常见的SEGV,这是由无效内存访问导致的错误:
- 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.
- 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.
- 访问了具有错误权限的页面。例如,它是只读的,但您的代码试图写入它。这将报告为SEGV_ACCERR。
- 访问的页面甚至根本没有映射到应用程序的地址空间。这通常是由于取消引用空指针或因小整数值损坏的指针而导致的。这被报告为SEGV_MAPERR。
Documentation of a sort (indexed Linux source code) for SEGV_MAPERR is here: http://lxr.free-electrons.com/ident?i=SEGV_MAPERR.
SEGV_MAPERR 的排序(索引 Linux 源代码)文档在这里:http://lxr.free-electrons.com/ident?i=SEGV_MAPERR 。
回答by Sev
It's a segmentation fault. Most probably a dangling pointer issue, or some sort of buffer overflow.
这是一个分段错误。很可能是悬空指针问题,或者某种缓冲区溢出。
SIGSSEGV
is the signal that terminates it based on the issue, segmentation fault.
SIGSSEGV
是基于问题,分段错误终止它的信号。
Check for dangling pointers as well as the overflow issue.
检查悬空指针以及溢出问题。
Enabling core dumps will help you determine the problem.
启用核心转储将帮助您确定问题。