Stack overflow question

Stack overflow question

Post by ujjwal bhoo » Thu, 03 Jul 2003 09:39:14



A basic question

When a program is first loaded into memory to be run, how much memory
is allocated for stack growth? If that limit is crossed by the running
program what happens.

Thanks

 
 
 

Stack overflow question

Post by Amri » Thu, 03 Jul 2003 15:11:13


Hi.

There will be a maximum size for the stack segement, whenever there is
a requirement for space for a new frame, It will create a Fault and
the Fault handler will be invoked. Then sbrk() is called which will
allocate some more space. This will be repeated till all the user
quota is consumed.

Thanks
Amrith

 
 
 

Stack overflow question

Post by ujjwal bhoo » Fri, 04 Jul 2003 02:54:59


But my undrestanding is that whenever a processs tries to access a
virtual address which has not been allocated for it (for example the
virtual address space between stack and dynamic memory region) than it
results in a fault that terminates the program. If this is the same
kind of fault than how does fault handler differentiate between  this
and betwwen the fault due to stack growth.

Thanks


> Hi.

> There will be a maximum size for the stack segement, whenever there is
> a requirement for space for a new frame, It will create a Fault and
> the Fault handler will be invoked.
> Then sbrk() is called which will
> allocate some more space. This will be repeated till all the user
> quota is consumed.

> Thanks
> Amrith

 
 
 

Stack overflow question

Post by Amri » Fri, 04 Jul 2003 11:14:35


Basically there are three types of events belong to this category
fault, abort and trap
page fault do not cause a process to abort. When a page fault is
generated the fault handler is executed and the sampe instruction
which cause the page fault is invoked again. But if it is abort event
then the process will be terminated.

Amrith

 
 
 

Stack overflow question

Post by ujjwal bhoo » Fri, 04 Jul 2003 16:18:52


Thanks for your reply Amrith.

But how the hardware knows whether to generate a page fault exception
or to generate a tereminating exception(abort). Because in both of the
following cases process is trying to access a virtual address which
has no corresponding phisical address allocated.

1.Stack over flow
2.Any other invalid address being accessed

ujjwal


> Basically there are three types of events belong to this category
> fault, abort and trap
> page fault do not cause a process to abort. When a page fault is
> generated the fault handler is executed and the sampe instruction
> which cause the page fault is invoked again. But if it is abort event
> then the process will be terminated.

> Amrith

 
 
 

Stack overflow question

Post by Holger van Kol » Sat, 05 Jul 2003 00:03:55


the hardware doesnt know at all. it just notifies the kernel of the page
fault

then the kernel looks if the address belongs to the addressspace of the
task. if yes, it creates the page.
if no, the proc will be terminated


> Thanks for your reply Amrith.

> But how the hardware knows whether to generate a page fault exception
> or to generate a tereminating exception(abort). Because in both of the
> following cases process is trying to access a virtual address which
> has no corresponding phisical address allocated.

> 1.Stack over flow
> 2.Any other invalid address being accessed

> ujjwal


>>Basically there are three types of events belong to this category
>>fault, abort and trap
>>page fault do not cause a process to abort. When a page fault is
>>generated the fault handler is executed and the sampe instruction
>>which cause the page fault is invoked again. But if it is abort event
>>then the process will be terminated.

>>Amrith

 
 
 

Stack overflow question

Post by ujjwal bhoo » Mon, 07 Jul 2003 05:16:02


Thanks a lot to all.
ujjwal

> the hardware doesnt know at all. it just notifies the kernel of the page
> fault

> then the kernel looks if the address belongs to the addressspace of the
> task. if yes, it creates the page.
> if no, the proc will be terminated


> > Thanks for your reply Amrith.

> > But how the hardware knows whether to generate a page fault exception
> > or to generate a tereminating exception(abort). Because in both of the
> > following cases process is trying to access a virtual address which
> > has no corresponding phisical address allocated.

> > 1.Stack over flow
> > 2.Any other invalid address being accessed

> > ujjwal


> >>Basically there are three types of events belong to this category
> >>fault, abort and trap
> >>page fault do not cause a process to abort. When a page fault is
> >>generated the fault handler is executed and the sampe instruction
> >>which cause the page fault is invoked again. But if it is abort event
> >>then the process will be terminated.

> >>Amrith

 
 
 

1. stack overflow question

I've run into a bug that looks like a stack corruption problem.
My C compiler/linker take no options concerning the size of stack
or heap.  So, how do I specify how big a stack I want?  Do I need
to specify this at all?  Are there any tools out there to help
detect stack problems  (yes I've run lint).

Replies by email please, thanks in advance.

2. ? [ rsh 'procedures' --> Permission Denied ] ?

3. Buffer Overflows: Question about the internals of process creation and stack maintenence.

4. More USB changes for 2.5.53

5. Handling stack-overflow?

6. root password, bootable floppies

7. Stack overflow

8. Can't compile net2 source code?!?

9. Stack overflow ?

10. stack overflow vulnerabilities

11. *URGENT* PLEASE HELP: GNU bison error "Parser stack overflow"

12. Stack Overflow