473,785 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stack depth problem

PJ6
I have an algorithm that processes data recursively. When I'm testing it
works fine, but when I feed it data from the actual application, I get
"stack overflow". What bothers me is that the data my recursive processor is
seeing in production is identical to the test data; the only difference is
that now the processor must go deeper into an object model to get the values
with which it is working. I trace things through, there is no out of control
recursion. I've never seen this before, but the stack just craps out on a
legitimate path of execution. Not enough room. Before I rewrite my
processor, I'd like to know, is there a way of increasing stack depth?

I'm probably going to have dump the recursion since data can change... so
this question is more academic than anything else.

Paul
Mar 25 '07 #1
2 3051
"PJ6" <no***@nowhere. netwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
>I have an algorithm that processes data recursively. When I'm testing it
works fine, but when I feed it data from the actual application, I get
"stack overflow". What bothers me is that the data my recursive processor
is seeing in production is identical to the test data; the only difference
is that now the processor must go deeper into an object model to get the
values with which it is working. I trace things through, there is no out of
control recursion. I've never seen this before, but the stack just craps
out on a legitimate path of execution. Not enough room. Before I rewrite my
processor, I'd like to know, is there a way of increasing stack depth?
Yes, there is. You can use the STACKSIZE in a module definition file or the
/STACK:n where n is the size in bytes of the maximum amount of stack you
expect to use.

Regards,
Will
Mar 25 '07 #2
PJ6 wrote:
I have an algorithm that processes data recursively. When I'm testing
it works fine, but when I feed it data from the actual application, I
get "stack overflow". What bothers me is that the data my recursive
processor is seeing in production is identical to the test data; the
only difference is that now the processor must go deeper into an
object model to get the values with which it is working. I trace
things through, there is no out of control recursion. I've never seen
this before, but the stack just craps out on a legitimate path of
execution. Not enough room. Before I rewrite my processor, I'd like
to know, is there a way of increasing stack depth?
I'm probably going to have dump the recursion since data can
change... so this question is more academic than anything else.
You can increase the stack size for any threads that you create by passing a
larger stack size to CreateThread (or _beginthreadex) . For the main entry
point of the application, you can increase the stack size using the linker
option /STACK:size_in_b ytes when the EXE is linked (or with the STACKSIZE
directive in a .DEF file, or by using EDITBIN on the EXE after linking).
Note that if you're not building the EXE, the only recourse you have is to
create a new thread with the larger size.

I'd agree though - if you're using up a 1Mb stack, you probably need to
think about a non-recursive approach.

-cd


Mar 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7742
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is how this would work with class objects. In this case do you have to push the object on the stack at the start of every public procedure etc. in the class and pop it off at the end? I can't see how else you can know which object is active - or...
4
5112
by: chandra.somesh | last post by:
I recently was having trouble converting implementaion of recursions using stack. While single level of recursions are quite intuitive , it is when we have more than one recursive calls in the function that the problem arises.Consider for example a simple postorder traversal void post(struct node * p) { if(p==NULL) return;
3
1593
by: alanwo | last post by:
For recursive search for files, like http://support.microsoft.com/default.aspx?scid=KB;EN-US;306666, it may lead to "out of stack" error if searching too many files, say millions of files. Do you all experts have any solution for this situation?
13
25565
by: Ben R. Bolton | last post by:
The documentation indicates that the threads "default stack size" is 1MB. The work "default" implies that it can be changed. Is it possible to change the StackSize in .NET? If so how? Is it possible to determine the amount of memory used in the current stack? Any assistance would be appreciated. Ben
2
2221
by: 63q2o4i02 | last post by:
Hi, I've written a top-down recursive decent parser for SPICE circuit descriptions. For debugging purposes, I wanted each production rule/function to know what its own name was, so at the beginning of each rule/function, I make a call to inspect.stack() (I think...) and that fetches the name from someplace. However, with a bunch of test text input, this takes ~10 seconds to run. When I comment out the inspect.stack() function from each...
6
2646
by: Daz | last post by:
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?
6
1440
by: Tony | last post by:
Is there any value to pursuing program designs that mimimize the mainline call stack? For example, within main() I could code up something like: while(GetMsg(m)) DispatchMsg(m); instead of doing Program.Run() from main() or even worse calling Run() from the Program constructor.
13
3847
by: softwaredoug | last post by:
I can't see to easily find this on google or in a newsgroup Is there a standard function/macro/whatever you can call and determine the distance in a C program how deep one is in the C call stack from main. Something along the lines: int main() {
3
1204
by: Martin Manns | last post by:
Hi, Calling methods of other object instances seems quite expensive on the stack (see example below). Is there a better way of traversing through methods of instances that are connected in a cyclic graph? (The real program's graph contains multiple successors in lists.) class A(object): def __init__(self): self.i = 0
0
9647
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
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
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
5396
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
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.