Questions tagged [callstack]

A stack that stores details of the functions called by a program in sequence, so that each function can return on completion to the code that called it.

A call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack".

A call stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing. An active subroutine is one that has been called but is yet to complete execution after which control should be handed back to the point of call. Such activations of subroutines may be nested to any level (recursive as a special case), hence the stack structure.

Source: Wikipedia (Call Stack)

For errors relating to overflowing the call stack use .

1119 questions
1043
votes
38 answers

How do you find out the caller function in JavaScript?

function main() { Hello(); } function Hello() { // How do you find out the caller function is 'main'? } Is there a way to find out the call stack?
Ray Lu
  • 26,208
  • 12
  • 60
  • 59
737
votes
38 answers

Maximum call stack size exceeded error

I am using a Direct Web Remoting (DWR) JavaScript library file and am getting an error only in Safari (desktop and iPad) It says Maximum call stack size exceeded. What exactly does this error mean and does it stop processing completely? Also any…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
304
votes
7 answers

How do you print out a stack trace to the console/log in Cocoa?

I'd like to log the call trace during certain points, like failed assertions, or uncaught exceptions.
robottobor
  • 11,595
  • 11
  • 39
  • 37
281
votes
6 answers

Explain the concept of a stack frame in a nutshell

It seems that I get the idea of call stack in programming language design. But I cannot find (probably, I just don't search hard enough) any decent explanation of what stack frame is. So I would like to ask someone to explain it to me in a few…
ikostia
  • 7,395
  • 6
  • 30
  • 39
203
votes
4 answers

How can I rethrow an exception in Javascript, but preserve the stack?

In Javascript, suppose I want to perform some cleanup when an exception happens, but let the exception continue to propagate up the stack, eg: try { enterAwesomeMode(); doRiskyStuff(); // might throw an exception } catch (e) { …
Geoff
  • 4,372
  • 5
  • 25
  • 29
184
votes
14 answers

print call stack in C or C++

Is there any way to dump the call stack in a running process in C or C++ every time a certain function is called? What I have in mind is something like this: void foo() { print_stack_trace(); // foo's body return } Where…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
136
votes
4 answers

What are CFI directives in Gnu Assembler (GAS) used for?

There seem to be a .CFI directive after every line and also there are wide varieties of these ex.,.cfi_startproc , .cfi_endproc etc.. more here. .file "temp.c" .text .globl main .type main, @function main: .LFB0: .cfi_startproc …
claws
  • 52,236
  • 58
  • 146
  • 195
127
votes
7 answers

How exactly does the callstack work?

I'm trying to get a deeper understanding of how the low level operations of programming languages work and especially how they interact with the OS/CPU. I've probably read every answer in every stack/heap related thread here on Stack Overflow, and…
Christoph
  • 26,519
  • 28
  • 95
  • 133
116
votes
9 answers

What is the direction of stack growth in most modern systems?

I am preparing some training materials in C and I want my examples to fit the typical stack model. What direction does a C stack grow in Linux, Windows, Mac OSX (PPC and x86), Solaris, and most recent Unixes?
Uri
  • 88,451
  • 51
  • 221
  • 321
113
votes
13 answers

What causes a java.lang.StackOverflowError

What can cause a java.lang.StackOverflowError? The stack printout that I get is not very deep at all (only 5 methods).
Ivan
  • 1,159
  • 2
  • 8
  • 4
111
votes
3 answers

Android Studio - Where can I see callstack while debugging an android app?

While on a break point, how do I see the call stack to find the callee method/function?
IsmailS
  • 10,797
  • 21
  • 82
  • 134
105
votes
12 answers

Node.js - Maximum call stack size exceeded

When I run my code, Node.js throws a "RangeError: Maximum call stack size exceeded" exception caused by too many recursive calls. I tried to increase Node.js stack size by sudo node --stack-size=16000 app, but Node.js crashes without any error…
user1518183
  • 4,651
  • 5
  • 28
  • 39
100
votes
17 answers

How does the stack work in assembly language?

I'm currently trying to understand how the stack works, so I've decided teach myself some assembly language, I'm using this book: http://savannah.nongnu.org/projects/pgubook/ I'm using Gas and doing my development on Linux Mint. I'm a bit confused…
handles
  • 7,639
  • 17
  • 63
  • 85
96
votes
9 answers

How do I print functions as they are called?

In debugging a Python script, I'd really like to know the entire call stack for my entire program. An ideal situation would be if there were a command-line flag for python that would cause Python to print all function names as they are called (I…
James
  • 1,485
  • 2
  • 16
  • 21
89
votes
4 answers

Are stack variables aligned by the GCC __attribute__((aligned(x)))?

i have the following code: #include int main(void) { float a[4] __attribute__((aligned(0x1000))) = {1.0, 2.0, 3.0, 4.0}; printf("%p %p %p %p\n", &a[0], &a[1], &a[2], &a[3]); } And i have the following…
cojocar
  • 1,782
  • 2
  • 18
  • 22
1
2 3
74 75