By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,329 Members | 1,731 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,329 IT Pros & Developers. It's quick & easy.

Stack overflows

P: n/a
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

Jun 20 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Daz wrote:
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.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 20 '06 #2

P: n/a
Daz

Phlip wrote:
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.

Jun 20 '06 #3

P: n/a
Daz wrote:

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 :)

--
Ian Collins.
Jun 20 '06 #4

P: n/a
Phlip <ph******@yahoo.com> wrote:
Daz wrote:
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?

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
Jun 21 '06 #5

P: n/a

"Steve Pope" <sp*****@speedymail.org> wrote in message
news:e7**********@blue.rahul.net...

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


Jun 21 '06 #6

P: n/a
Howard <al*****@hotmail.com> wrote:
"Steve Pope" <sp*****@speedymail.org> wrote in message
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.


Thanks, that makes more sense.

Steve
Jun 22 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.