Go To StackoverFlow.com


What is SEGV_MAPERR, why does it always come up with SIGSEGV?

2009-06-16 07:29
by Geek


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.

Check for dangling pointers as well as the overflow issue.

Enabling core dumps will help you determine the problem.

2009-06-16 07:33
by Sev


There are two common 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.

Documentation of a sort (indexed Linux source code) for SEGV_MAPERR is here: http://lxr.free-electrons.com/ident?i=SEGV_MAPERR.

2015-01-23 18:36
by ahcox
Why is http://stackoverflow.com/a/1000010/358475 marked as the answer when this one is more complete and helpful - OldPeculier 2015-04-28 16:56
The question and other answer are much older than my answer. I did edit the other answer to improve it at least - ahcox 2015-04-28 18:25
It would be interesting to know the circumstances that differentiate these from EXCBADACCESS exception types. e.g. is the page mapped but not allocated (/ recently deallocated) - Bobjt 2016-03-01 21:05
One example of SEGV_MAPERR is stack overflow (no pun intended). : - Antti Haapala 2016-07-07 16:14
There are even more SEGV types: http://elixir.free-electrons.com/linux/latest/source/include/uapi/asm-generic/siginfo.h#L22 - tomasz 2017-10-30 12:12
@tomasz Yes, the last version with just the two was 3.18: http://elixir.free-electrons.com/linux/v3.18.78/source/include/uapi/asm-generic/siginfo.h#L20 - ahcox 2017-10-31 18:05