Jump to content
Sign in to follow this  
d0es_n0t_c0mpute

What is a stack/call stack/stack frame

Recommended Posts

Hello everyone,

 

I'm sure for most of you this is probably a pretty stupid question. Right now I'm in my first two years of college learning java and python with hopes to be a pen tester. In my free time I'm trying to learn exploit development and the terms stack frame and call stack keep popping up. I've looked on the internet on countless sights to find out what these terms mean but it seems to me a pretty abstract idea. I was wondering if someone could break these terms down for me to understand.

Share this post


Link to post
Share on other sites

First up, I'm not into Java so this is generic type info.

 

A stack in computing terms is a temporary storage area which is generally used for one or more of - saving caller's address when entering a subroutine or interrupt service routine, area to put parameters for a service, area to save/restore CPU registers.

A system might have anything from one stack for the entire machine to 1-2 stacks for the system and one or more per running task.

In the modern day, it's generally a case of there being quite a lot of them.

Stacks can be FIFO (First In, First Out) or LIFO (Last In, First Out). The more common type is LIFO - also FIFO might at times be referred to as a "ring buffer".

Entering information onto a stack is usually called a "push", getting it back is "pull".

 

In the sense of Java, my guestimation would be - a stack is for push/pull of parameters. Call stack is for register save/call address. This might be well out so it's worth looking up.

Stack Frame - in the sense of programming and CPUs, stack entries will usually have multiple standard types. So a stack frame is simply a set of data that has been put on the stack.

e.g. a stack frame might simply contain a return address, or it might contain a return address and a bunch of saved registers.

 

Also, in higher level languages a stack will usually be used to retain information for active loops and subroutines. e.g. for loops, an entry might contain exit test condition and address of the start of the loop, for sub might contain address which called the sub.

Edited by Rybags

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×