Reputation: 157
According to various sourcess Linux at x86 tries to get rid of segmentation by setting all 4 segments (user code, user data, kernel code, kernel data) to base 0x00000000 and limit 0xfffff, and handles memory access at paging level.
With this setup, why is it still possible to get SIGSEGV (segfault)?
Or is SIGSEGV used in broader "access violation" meaning here and actual cause is pagefault?
Upvotes: 1
Views: 2533
Reputation: 16441
As you say, SIGSEGV is used as "access violation".
The actual cause is that you accessed a pointer to memory that isn't mapped in the current process.
There are several variations of this (e.g. non existent pages, no existent segments, kernel pages, writing to read only pages), they all end up with SIGSEGV.
Upvotes: 2
Reputation: 798626
A page fault will only result in a segmentation violation if there is an access to a page without backing memory; otherwise the MM will attempt to load the page from disk or swap. A segmentation violation is also possible if a process tries to access the bottom 64KiB of memory, as it is protected in order to catch silly programmer errors such as NULL dereferencing.
Upvotes: 2