473,842 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stack overflows

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
6 2650
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
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
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
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

"Steve Pope" <sp*****@speedy mail.org> wrote in message
news:e7******** **@blue.rahul.n et...

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
Howard <al*****@hotmai l.com> wrote:
"Steve Pope" <sp*****@speedy mail.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6730
by: Allen | last post by:
Hi all, What are some different approaches to dealing with stack overflows in C++? I'm especially interested in approaches concerned with speed for infrequent overflows. -- Best wishes, Allen
13
2094
by: Will Pittenger | last post by:
I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does overflow. All I know is that the program is either stopped due to an exception at the end of Main or has exited after the Stack Overflow exception. (Both cases are Debug builds running in the debugger.) After a lot of trial and error (mostly...
19
3151
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form (nested), three list views, one tree control with up to 30,000 nodes, maybe 15 comboboxes (half of which have a large recordset as rowsource), 20 or so buttons and around 30 text boxes (not to mention the images, labels, etc and around 1000 lines...
87
5589
by: CJ | last post by:
Hello: We know that C programs are often vulnerable to buffer overflows which overwrite the stack. But my question is: Why does C insist on storing local variables on the stack in the first place? I can see two definite disadvantages with this: 1) deeply nested recursive calls to a function (especially if it defines
0
9872
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10945
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10314
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7038
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5696
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4089
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.