473,465 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to increase the stack limit in c?

8 New Member
Hi,

I am getting parser stack overflow at compile time.

Kindly give ur valuable solutions to this problem.
Feb 14 '07 #1
10 2305
sicarie
4,677 Recognized Expert Moderator Specialist
Hi,

I am getting parser stack overflow at compile time.

Kindly give ur valuable solutions to this problem.
Can we see the code causing the stack overflow?
Feb 14 '07 #2
hirak1984
316 Contributor
ya because increase of stack limit is not in our hand.

you have to talk with MDs of intel and amd

Can we see the code causing the stack overflow?
Feb 14 '07 #3
AdrianH
1,251 Recognized Expert Top Contributor
ya because increase of stack limit is not in our hand.

you have to talk with MDs of intel and amd
Actually, this is not correct. The stack is allocated by the programme, but is set to a default value. You will have to look in the compiler's or IDE's manual to set the stack size. You can also set this when spawning a new thread, but is a bit overkill if you are writing a single-threaded app.

If you want help with setting the default stack size, state the compiler and IDE (if any) you are using. Someone may be able to point you in the right direction.

That said, the stack is usually big enough for most apps, so it could be you have a infinite recursion problem in your code. Posting the output stating where the problem is occurring, the function where this is occurring and probably the function that is calling the function that is causing the error would allow us to help in that regard. If you don't know where the problem is occurring, take a look in your code for recursive functions and post them, and we will see what we can do.

Hope this helps.


Adrian
Feb 14 '07 #4
suppaduppa
5 New Member
increasing the limit of stack is not possible and there could be error in the program
enjoy.......
Feb 19 '07 #5
bawa
8 New Member
Actually, this is not correct. The stack is allocated by the programme, but is set to a default value. You will have to look in the compiler's or IDE's manual to set the stack size. You can also set this when spawning a new thread, but is a bit overkill if you are writing a single-threaded app.

If you want help with setting the default stack size, state the compiler and IDE (if any) you are using. Someone may be able to point you in the right direction.

That said, the stack is usually big enough for most apps, so it could be you have a infinite recursion problem in your code. Posting the output stating where the problem is occurring, the function where this is occurring and probably the function that is calling the function that is causing the error would allow us to help in that regard. If you don't know where the problem is occurring, take a look in your code for recursive functions and post them, and we will see what we can do.

Hope this helps.


Adrian

Thanks for your valuable time… I have solved this problem….
Feb 21 '07 #6
bawa
8 New Member
ya because increase of stack limit is not in our hand.

you have to talk with MDs of intel and amd


Thanks for ur valuable time..... Stack size is something related with system software i.e compiler.. as per I know stack is a block of memory with LIFO principle, created by system software i.e compiler.... Please correct me if i am wrong
Feb 21 '07 #7
AdrianH
1,251 Recognized Expert Top Contributor
Thanks for ur valuable time..... Stack size is something related with system software i.e compiler.. as per I know stack is a block of memory with LIFO principle, created by system software i.e compiler.... Please correct me if i am wrong
I don't need to correct you as you are correct. That is the definition of the programme stack.

So how did you correct the problem?


Adrian
Feb 21 '07 #8
hirak1984
316 Contributor
well one small correction:

stack is a block of memory not created by compiler,but assigned to it by the processor

Thanks for ur valuable time..... Stack size is something related with system software i.e compiler.. as per I know stack is a block of memory with LIFO principle, created by system software i.e compiler.... Please correct me if i am wrong
Feb 21 '07 #9
AdrianH
1,251 Recognized Expert Top Contributor
well one small correction:

stack is a block of memory not created by compiler,but assigned to it by the processor
Hey, you want to get technical, there has to be a base stack that needs to be created for the programme. It is not assigned by the processor as the processor doesn't care. (boy this is going to get involved)

Here is a simplified but fairly accurate step by step of what is going on:
  1. You start off with an OS and an executable image file.
  2. The image file is loaded into memory.
  3. Somewhere in the image file states the size of the default stack.
  4. This stack memory is allocated by the OS.
  5. Somewhere in the image file states the code entry point.
  6. The OS sets the stack pointer register to the base of the stack and then executes the code at the entry-point. (there are also registers saved prior to this so that the OS’s task system can come back and possibly pass the execution to another task if it is a multitasking system)

So, yes, the default stack isn't created by the compiler, it is defined by it. Also, every time you create a new thread, you must state the size of the stack for that thread but that call is put on the stack that is invoking the new thread call.

You cannot invoke a task, thread or fibre without an initial stack. This goes back to the OS, as the OS must have a running stack to create the stack of the image file it is about to execute. Even when the computer boots up, it has an initial stack and an entry point (stored in ROM somewhere) which will eventually be blown away when the OS boot loader takes over.

I hope this is clear, as this is a bit more detailed than I had intended to go. If you are in University, I recommend you take Operating Systems. It is a very interesting course.

TTFN,


Adrian
Feb 21 '07 #10
bawa
8 New Member
Hey, you want to get technical, there has to be a base stack that needs to be created for the programme. It is not assigned by the processor as the processor doesn't care. (boy this is going to get involved)

Here is a simplified but fairly accurate step by step of what is going on:
  1. You start off with an OS and an executable image file.
  2. The image file is loaded into memory.
  3. Somewhere in the image file states the size of the default stack.
  4. This stack memory is allocated by the OS.
  5. Somewhere in the image file states the code entry point.
  6. The OS sets the stack pointer register to the base of the stack and then executes the code at the entry-point. (there are also registers saved prior to this so that the OS’s task system can come back and possibly pass the execution to another task if it is a multitasking system)

So, yes, the default stack isn't created by the compiler, it is defined by it. Also, every time you create a new thread, you must state the size of the stack for that thread but that call is put on the stack that is invoking the new thread call.

You cannot invoke a task, thread or fibre without an initial stack. This goes back to the OS, as the OS must have a running stack to create the stack of the image file it is about to execute. Even when the computer boots up, it has an initial stack and an entry point (stored in ROM somewhere) which will eventually be blown away when the OS boot loader takes over.

I hope this is clear, as this is a bit more detailed than I had intended to go. If you are in University, I recommend you take Operating Systems. It is a very interesting course.

TTFN,


Adrian

Thank for your valuable time... and good explanation about the stack process.
I have solved my problem by putting more nested if else if ... now that problem has been solved... my that code file is of around 6000 lines of code... that error was bcoz of if conditions.. only
Feb 27 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

15
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...
11
by: Dan Elliott | last post by:
Hello all, I am writing a program which needs to run as quickly as possible, but holds a lot of data in memory (around 1GB for a usual run). Is this too much memory to even consider putting...
12
by: jimjim | last post by:
Hello, 1. As the subject sugests, are the objects created in the stack guarranted to have been created? 2. How can I verify this? (e.g. for objects created in the heap A *a = new A one can...
3
by: gary | last post by:
Hi, 1. About all C/C++ compilers, Does stack increase from high address to low address and heap grow increase from low to high? What on earth decides their increase direction, CPU architecture, OS...
9
by: Ajay | last post by:
Hi all, Can I know what is the stack space and heap space allocated by the compiler.Can i increase it or decrease it.if yes,pleae tell me theway to do it.Thanks in advance. Cheers, Ajay
1
by: HopfZ | last post by:
Internet Explorer 6 bookmarklets(favlets) has size limit. And its size limit depend on the kind of code. For example, CODE A and CODE B (below) are both at their size limit. CODE A does not work...
8
by: gypsy3001 | last post by:
I inherited some code and got a segmentation fault on the following line: unsigned short localImage; It's really baffling and I can't think of what could cause this problem. The following are...
4
by: SP | last post by:
Hi, I've a Stack. Now I would use this to mantain a LIFO objects chain. My problem is that I want to limit the Stack dimension. If the Stack is full and I want to add a object, I eant to remove...
1
by: bawa | last post by:
I am getting stack over flow error. Kindly help me regarding this...
4
by: lianne.ribeiro | last post by:
I am using Visual C++ 6 IDE,with 512MB RAM. I have coded a recursive function that has a correct end condition for recursion. There is no infinite recursion. For some input data,the recursive...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
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 ...

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.