Jump to content


Photo

What is a stack/call stack/stack frame


  • Please log in to reply
2 replies to this topic

#1 d0es_n0t_c0mpute

d0es_n0t_c0mpute

    Apprentice

  • Quark
  • 107 posts

Posted 08 March 2015 - 08:07 AM

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.



#2 Rybags

Rybags

    Immortal

  • Super Hero
  • 34,809 posts

Posted 08 March 2015 - 10:46 AM

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, 08 March 2015 - 10:52 AM.


#3 .:Cyb3rGlitch:.

.:Cyb3rGlitch:.

    Hero

  • Mod
  • 21,368 posts

Posted 08 March 2015 - 11:09 AM

See if this helps:

 


"We are a way for the cosmos to know itself." - Carl Sagan
"I do not fear death. I had been dead for billions and billions of years before I was born, and had not suffered the slightest inconvenience from it." - Mark Twain
 
An open mind is willing to consider new ideas, while provisionally accepting those backed by empirical evidence, and provisionally rejecting those without.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users