Questions tagged [stackoverflow]

Stack overflow is a situation when the stack is full and any item that is pushed onto it will not be incorporated and will cause stack overflow to occur. This is NOT about the website StackOverflow.com.

Stack overflow is a situation when the stack is full and any item that is pushed onto it will not be incorporated and will cause stack overflow to occur. It generally throws an exception in programming languages like Java or Python.

12 questions
55
votes
4 answers

How much stack usage is too much?

Lately when I've been writing C or C++, I'll declare all my variables on the stack just because it's an option, unlike with Java. However, I've heard that it's a bad idea to declare large things on the stack. Why exactly is this the case? I…
Elliot Way
  • 661
  • 1
  • 5
  • 5
28
votes
2 answers

Is it *ever* okay to catch StackOverflowError in Java?

I used to think that it's not, but yesterday I had to do it. It's an application that uses Akka (an actor system implementation for the JVM) to process asynchronous jobs. One of the actors performs some PDF manipulation, and because the library is…
Ionuț G. Stan
  • 717
  • 6
  • 12
24
votes
1 answer

How often is seq used in Haskell production code?

I have some experience writing small tools in Haskell and I find it very intuitive to use, especially for writing filters (using interact) that process their standard input and pipe it to standard output. Recently I tried to use one such filter on a…
Giorgio
  • 19,486
  • 16
  • 84
  • 135
16
votes
3 answers

How many are too many nested function calls?

Quoted from MSDN about StackOverflowException: The exception that is thrown when the execution stack overflows because it contains too many nested method calls. Too many is pretty vague here. How do I know when too many is really too many?…
marco-fiset
  • 8,721
  • 9
  • 35
  • 46
15
votes
4 answers

When there's no TCO, when to worry about blowing the stack?

Every single time there's a discussion about a new programming language targetting the JVM, there are inevitably people saying things like: "The JVM doesn't support tail-call optimization, so I predict lots of exploding stacks" There are thousands…
Cedric Martin
  • 1,067
  • 10
  • 16
7
votes
2 answers

Ensure that callbacks registration and triggering don't cause infinite recursion

I just spent a long, miserable week debugging a stack-overflow in a C++/Qt application. The fundamental problem was that I had a function that accepted a callback, and in certain cases the callback was triggered (in another function) before the…
4
votes
6 answers

Heap overflow vs stack overflow

So as a general rule to avoid a stack overflow, big objects should be allocated to the heap (correct me if I am wrong). But, since the heap and the stack expand towards each other, wouldn't this cause heap overflow or alternatively limit the space…
Rayhunter
  • 151
  • 1
  • 1
  • 2
3
votes
1 answer

Structure of stack of a function call

I've been reading Aleph One's paper on Smashing the Stack for Fun and Profit. I wrote down example1.c from his paper, modified it a bit to see what the stack looks like on my system. I'm running Ubuntu (64-bit) on a VM on an Intel i5 M 480. The…
Torcellite
  • 133
  • 6
2
votes
2 answers

How do I prevent stack overflows from happening in this command structure with callbacks?

I have a set of jobs that I need executed. The entity that manages these jobs is responsible for composing the jobs and starting them. When a job is finished, the job uses a callback function to inform the entity of the result of the job (Whether it…
Zimano
  • 232
  • 2
  • 12
2
votes
1 answer

What happens when both heap and stack are full?

Suppose I am using a very heavy applications(or you can say that it is a very bad code which keeps on allocating memory on heap and won't free it and also uses recursion) Now after some point of time both heap and stack will have no space to…
Nullpointer
  • 141
  • 1
  • 1
  • 5
-1
votes
1 answer

How can we extend a packet in the case of an overflow?

I have asked this question in stackOverflow, but I guess that maybe softwareEngineering is more appropriate. (here is the question in stackOverflow) I have frames sized with a fixed size of 7 values (t_i, i in {1..7}). Each value is stored on 2…
Nour
  • 13
  • 3
-3
votes
1 answer

stack based vs heap based overflow

Why is it more difficult to perform a heap based buffer overflow than a stack based? (regarding x86 architecture) I thought it could be the fact that heaps are allocating memory dynamically. But is there more than this?
radscheit
  • 99
  • 6