stack trace
A stack trace is a list printed at the moment of an error: it shows through what nested steps the program reached the point where the error occurred.
In plain terms
Imagine burning a roux while cooking. To understand what happened, you trace the steps backward: you made the roux for the soup, the soup for lunch, and lunch for the guests. A stack trace does the same for a program: it shows which task triggered which other, all the way to the error location.
Programs consist of small, mutually calling parts, called functions. When one encounters an error, the system prints the entire call chain: file names, line numbers, and the type of error. This strange, often frighteningly long text is the stack trace.
A plain error message only states that something is wrong. A stack trace also shows where the error occurred and the path the program took to get there. Therefore, this is the primary clue for developers and coding agents in debugging: the agent reads it, finds the marked line, and tries to fix the code there.
How it works
- While running, the program keeps track in a "stack" of which function it is currently in and where it was called from. Every new call goes to the top of the stack, like another plate on a stack of plates.
- When a function finishes, it is removed from the top of the stack, and the program returns to where the call originated.
- If an error occurs, the runtime records a snapshot of the call stack. For each level it notes the function name and, if that information is available, the file and line number.
- It outputs this list to the screen or a log file along with the error type and a short description. The actual location of the error appears at the beginning of the list (for example in Java) or at the end (for example in Python), depending on the language.
- The developer or coding agent reads through the list, finds the first affected line of its own code, and starts the fix from there.
An everyday example
You ask an AI assistant to write a short program to sum your bills, but upon execution, a dozen lines of English text appear with the label 'Traceback'. If you copy this verbatim into the conversation, the assistant reads from it which line caused the program to fail and why, then provides a corrected version.
Who is affected
A common misconception
Limits and risks
- A stack trace shows where the error surfaced, not necessarily where it originated: the real cause may lie in an earlier step or in faulty input data.
- It may contain sensitive data (file paths, usernames, internal system names), so review it before copying it to a public forum or external AI service.
- A coding agent may easily treat only the symptom: it removes the error message, but the underlying logical error remains. The fix must therefore always be verified.
- For parallel-running or highly optimized programs, the list may be incomplete or misleading because part of the call chain is not visible in it.
Similar, but not the same
- error message – The error message briefly states what is wrong. The stack trace also shows the path the program took to reach the error.
- log file – The log is the continuous chronicle of a program's operation. A stack trace is a snapshot of a single error moment, often included in the log.
- core dump – A memory dump saves the program's entire memory contents at the moment of the crash. A stack trace shows only the call chain, in readable form. With a debugger, the stack trace can also be reconstructed from the memory dump afterward.
Related concepts
debugging, software development
–
error message, Call stack, exception, log file, coding agent, programhiba, testing, terminal
A brief history
The basis of a stack trace is the data structure called the stack. Alan Turing already described the stack-like storage of return addresses in 1946. German mathematicians Friedrich L. Bauer and Klaus Samelson filed a patent for the stack in 1957, originally for evaluating expressions. Printing the call chain later became a natural part of error handling in programming languages. Today, most widely used languages offer it built-in; in C and C++, however, a debugger program or a separate library is typically required.
Where things stand
For decades, it has been a basic tool of programming. By the end of 2026, coding agents also read it routinely: they run the code, interpret the stack trace and try to fix the problem on their own.
Also known as
stack trace · stacktrace · stack dump · call chain · traceback · backtrace · stack backtrace
Sources
- Wikipedia: Stack trace
- Python documentation: traceback — Print or retrieve a stack traceback
- MDN Web Docs: Error.prototype.stack
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.