Skip to main content
CSArchitecture & RuntimeDiagramBeginner

Call Stack

KO: 콜 스택 (Call Stack)·EN: Call Stack·JA: コールスタック

A LIFO runtime structure storing active function frames (local variables, arguments, and return addresses) to manage execution flow and stack traces

Table of Contents

Structure Diagram

Call Stack Frame Push/Pop Execution TraceTap a node
Call (PushCall (PushReturn (PoFrame 1: …Frame 2: …Frame 3: …
ROOTFrame 1: main()
1 link
Quick Answer

What is Call Stack?

A LIFO runtime structure storing active function frames (local variables, arguments, and return addresses) to manage execution flow and stack traces. It is a core concept in Architecture & Runtime within CS.

Core Principles

The Call Stack is a LIFO runtime stack tracking active function calls so execution always knows where to return.

  • Stack Frames: Each invocation pushes a frame containing arguments, local variables, and the return address; returning pops the frame immediately.
  • Stack Traces: When an unhandled exception occurs, the runtime walks the active frames from top to bottom to generate the diagnostic trace.

Practical Takeaways

  • Preventing Stack Overflows: Missing recursion base cases or ultra-deep call chains exhaust the thread's stack limit.
  • Async Stack Traces: Callbacks scheduled through an event loop run on a fresh call stack; using async/await helps runtimes preserve readable async stack traces.
  • Flame Graphs: Sampling profilers (perf, pprof, DevTools) repeatedly capture the call stack to pinpoint CPU hotspots.

Notable Examples

  • Error Monitoring (Sentry / Datadog): Grouping incidents by call stack signatures.
  • CPU Flame Graphs: Visualizing time spent across nested function call chains.