IT lexicon › Programming › Stack frame

Stack frame

Programming På svenska → Updated: 2026-11-05

The slice of the call stack that belongs to one active function call: return address, saved registers, local variables and whatever got spilled out of registers.

The frame is built in the function's prologue and torn down in its epilogue. The classic x86 pattern is push rbp; mov rbp, rsp; sub rsp, N on the way in and leave; ret on the way out. Because the stack grows downward, local buffers sit below the return address, and anyone writing past the end of an array eventually reaches it. That is the entire premise of the classic buffer overflow, and the reason compilers now plant a canary between buffers and the return address.

Not every function needs a frame. A leaf function that fits in registers often skips it entirely, and a tail call can reuse the caller's. A debugger's backtrace is, at heart, a walk from frame to frame.

← Back to the lexicon