page fault and SIGSEGV

  • Follow


hi,

When a function call is made if the stack frame grows to an address which is 
beyond what is currently allocated it leads to a page fault exception. Kernel 
while handling this allocates a new page for the stack and maps it in into 
the address space of the process. When this kind of page fault exception 
occurs does the kernel send a SIGSEV to the process ?(my guess is no because
the default action for SIGSEV is abort of the process).

13.3 in 'Unix Internals' by Uresh Vahalia says..
----
In all such cases (Bounds error, Validation error or Protection error), the
MMU raises an exception and passes control to a handler in the kernel. Such
an exception is called page fault, and the fault handler is passed the 
offending virtual address as well as the type of fault (validation or 
protection - bounds errors result in a validation fault). The handler may
try to service the fault by bringing the page into memeory or notify the
process by sending it a signal (usually SIGSEGV)
---

Author says 'kernel *may* try to service the fault by brining the page into
memory of send SIGSEV'. I think for cases like an infinite recursion where 
the entire stack space is exhausted SIGSEGV will be sent.

What are the cases in which kernel can't bring in the page and resort to 
sending a SIGSEGV ? I presume kernel won't do both for a page fault exception.

Other than SIGSEGV what other signal can be generated in this context ?
(Author says 'usually SIGSEGV')

TIA,
Santhosh.
0
Reply salsacts (2) 8/10/2004 11:33:04 AM

santhosh wrote:
> hi,
> 
> When a function call is made if the stack frame grows to an address which is 
> beyond what is currently allocated it leads to a page fault exception. Kernel 
> while handling this allocates a new page for the stack and maps it in into 
> the address space of the process. When this kind of page fault exception 
> occurs does the kernel send a SIGSEV to the process ?(my guess is no because
> the default action for SIGSEV is abort of the process).
If it sucesssfully maps the page, it shouln't affect the process in any way.

> Author says 'kernel *may* try to service the fault by brining the page into
> memory of send SIGSEV'. I think for cases like an infinite recursion where 
> the entire stack space is exhausted SIGSEGV will be sent.

> What are the cases in which kernel can't bring in the page and resort to 
> sending a SIGSEGV ? I presume kernel won't do both for a page fault exception.
If it e.g. runs out of virtual address space for the stack, or if it's 
really
out of physival ram. Some OS's sends SIGTERM,SIGQUIT or similar
as well, if it kills the process cause out of memory scenarioes.
0
Reply ISO 8/10/2004 11:52:43 AM


In article <5a1b8709.0408100333.51cb0211@posting.google.com>,
 salsacts@yahoo.com (santhosh) wrote:

> hi,
> 
> When a function call is made if the stack frame grows to an address which is 
> beyond what is currently allocated it leads to a page fault exception. Kernel 
> while handling this allocates a new page for the stack and maps it in into 
> the address space of the process. When this kind of page fault exception 
> occurs does the kernel send a SIGSEV to the process ?(my guess is no because
> the default action for SIGSEV is abort of the process).
> 
> 13.3 in 'Unix Internals' by Uresh Vahalia says..
> ----
> In all such cases (Bounds error, Validation error or Protection error), the
> MMU raises an exception and passes control to a handler in the kernel. Such
> an exception is called page fault, and the fault handler is passed the 
> offending virtual address as well as the type of fault (validation or 
> protection - bounds errors result in a validation fault). The handler may
> try to service the fault by bringing the page into memeory or notify the
> process by sending it a signal (usually SIGSEGV)
> ---
> 
> Author says 'kernel *may* try to service the fault by brining the page into
> memory of send SIGSEV'. I think for cases like an infinite recursion where 
> the entire stack space is exhausted SIGSEGV will be sent.
> 
> What are the cases in which kernel can't bring in the page and resort to 
> sending a SIGSEGV ? I presume kernel won't do both for a page fault exception.

It depends on whether the address you're trying to access is available 
to the process.  If you're accessing an address that's in your virtual 
address space but currently paged out, it will simply page it in 
transparently.  If you're growing the stack, it will also be handled 
automatically.  But if you dereference an invalid pointer, it will often 
point to memory that's not yet assigned to the process, and a SIGSEGV 
will be raised.

> Other than SIGSEGV what other signal can be generated in this context ?
> (Author says 'usually SIGSEGV')

If the system runs out of swap space so it can't grow the process, it 
could be killed with something like SIGTERM.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
0
Reply Barry 8/10/2004 12:21:35 PM

2 Replies
254 Views

(page loaded in 0.04 seconds)

Similiar Articles:













7/22/2012 1:34:49 AM


Reply: