48

What is the difference between the terms "Call Stack" and "Stack Trace" ?

2
  • Can't say I haven't wondered this myself Commented Sep 20, 2011 at 9:02
  • 6
    About 3 letters? </tongueincheek>
    – Amber
    Commented Sep 20, 2011 at 9:03

4 Answers 4

54

A call stack is typically "the current stack of operations" - i.e. while it's running.

A stack trace is typically a copy of the call stack which is logged at some sort of failure, e.g. an exception.

In other words, while you're debugging you will look at the current call stack - but when you look at logs, you'll get a stack trace. At least, that's my interpretation of the terms :)

10
  • I view it as the stack trace is like the result (trying to think of a better word) of your progress along the call stack? Or is that wrong?
    – AndrewC
    Commented Sep 20, 2011 at 9:04
  • @AndyC: I'm not sure I understand what "progress along the call stack" means.
    – Jon Skeet
    Commented Sep 20, 2011 at 9:05
  • Hmm, I'm potentially wrong then (either that or I'm really bad at explaining :) ). Sort of like if the call stack is the route you're going to take through the application then the stack trace shows you how you've done so far?
    – AndrewC
    Commented Sep 20, 2011 at 9:08
  • @Jon : So if I say: " Call Stack refers to an ongoing process whereas 'stack trace' refers to a log of a failed process " am I correct?
    – pencilCake
    Commented Sep 20, 2011 at 9:12
  • 1
    @pencilCake: Well, you can get a stack trace without it always being a failure - and even if there's a failure, it may be more localized than the whole process failing - but that's along the right lines, I think.
    – Jon Skeet
    Commented Sep 20, 2011 at 9:14
23

I think Wikipedia does a fairly good job at distinguishing between them:

a call stack is a stack data structure that stores information about the active subroutines of a computer program

A stack trace is a report of the active stack frames at a certain point in time during the execution of a program.

In other words, the call stack is the actual data structure in memory, while the stack trace is a snapshot of said data structure.

0
13

Call stack is a data structure storing information about active subroutines in a running program. Stack trace is a representation of the call stack.

-1

Call Stack is the raw executed code you see in the file. Stack Trace is the code that you see in the console. Simple as such.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.