Stack overflows

D

Daz

Hi everyone!

It is indeed, once again time for me to ask another stupid question.

I have been searching around on the net for quite a while, and can't
find anything that explains 'exactly' what a stack overflow is, or how
it's detected. I know that it's leterally putting too many objects on
the stack, but how many objects can you have on the stack, or do OSs
only allow a certain number of recursive calls to functions?

I apologise in advance if I am missing something here.

Regards

Daz
 
P

Phlip

Daz said:
It is indeed, once again time for me to ask another stupid question.

I have been searching around on the net for quite a while, and can't
find anything that explains 'exactly' what a stack overflow is, or how
it's detected. I know that it's leterally putting too many objects on
the stack, but how many objects can you have on the stack, or do OSs
only allow a certain number of recursive calls to functions?

I apologise in advance if I am missing something here.

You have been posting here long enough to notice all the screams over
off-topic questions, right?

The limit of your stack is implementation-defined, and the behavior when you
overflow it is either implementation-defined or undefined.

You could write a program that calls void foo() { foo(); } and run it to see
what happens. It might be a trappable error, or might be a GPF. All
completely off-topic, because only an on-topic newsgroup can tell you how
reliable the error will be, and how preventable, how recoverable, etc.
 
D

Daz

Phlip said:
Daz wrote:
You have been posting here long enough to notice all the screams over
off-topic questions, right?

The limit of your stack is implementation-defined, and the behavior when you
overflow it is either implementation-defined or undefined.

You could write a program that calls void foo() { foo(); } and run it to see
what happens. It might be a trappable error, or might be a GPF. All
completely off-topic, because only an on-topic newsgroup can tell you how
reliable the error will be, and how preventable, how recoverable, etc.

Off topic? Good point, I do apologise. I think I should put a bit more
thought into where I am posting as well as what I am posting.
 
I

Ian Collins

Daz said:
Off topic? Good point, I do apologise. I think I should put a bit more
thought into where I am posting as well as what I am posting.
If you are unsure where, mention you platform in your post and someone
will redirect you - but don't make a habit of it :)
 
S

Steve Pope

Phlip said:
Daz wrote:
You have been posting here long enough to notice all the screams over
off-topic questions, right?
The limit of your stack is implementation-defined, and the behavior when you
overflow it is either implementation-defined or undefined.
You could write a program that calls void foo() { foo(); } and run it to see
what happens. It might be a trappable error, or might be a GPF.

Somebody correct me if I'm wrong, but I believe the C++ standard
guarantees a recursion depth of 17 -- meaning the in the absence
of stack overflow you can call a function recursively to this
depth, whereas if you exceed the depth it may fail even if
there isn't a stack overflow.

Steve
 
H

Howard

Somebody correct me if I'm wrong, but I believe the C++ standard
guarantees a recursion depth of 17 -- meaning the in the absence
of stack overflow you can call a function recursively to this
depth, whereas if you exceed the depth it may fail even if
there isn't a stack overflow.

I think you're thinking about the suggested minimum value for the maximum
[guaranteed-to-work] depth of recursive template instantiations, not
anything having to do with the stack or recursive function calls.

-Howard
 
S

Steve Pope

I think you're thinking about the suggested minimum value for the maximum
[guaranteed-to-work] depth of recursive template instantiations, not
anything having to do with the stack or recursive function calls.

Thanks, that makes more sense.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top