how to increase the stack limit in c?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bawa
    New Member
    • Feb 2007
    • 8

    how to increase the stack limit in c?

    Hi,

    I am getting parser stack overflow at compile time.

    Kindly give ur valuable solutions to this problem.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by bawa
    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?

    Comment

    • hirak1984
      Contributor
      • Jan 2007
      • 316

      #3
      ya because increase of stack limit is not in our hand.

      you have to talk with MDs of intel and amd

      Originally posted by sicarie
      Can we see the code causing the stack overflow?

      Comment

      • AdrianH
        Recognized Expert Top Contributor
        • Feb 2007
        • 1251

        #4
        Originally posted by hirak1984
        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

        Comment

        • suppaduppa
          New Member
          • Oct 2006
          • 5

          #5
          increasing the limit of stack is not possible and there could be error in the program
          enjoy.......

          Comment

          • bawa
            New Member
            • Feb 2007
            • 8

            #6
            Originally posted by AdrianH
            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….

            Comment

            • bawa
              New Member
              • Feb 2007
              • 8

              #7
              Originally posted by hirak1984
              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

              Comment

              • AdrianH
                Recognized Expert Top Contributor
                • Feb 2007
                • 1251

                #8
                Originally posted by bawa
                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

                Comment

                • hirak1984
                  Contributor
                  • Jan 2007
                  • 316

                  #9
                  well one small correction:

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

                  Originally posted by bawa
                  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

                  Comment

                  • AdrianH
                    Recognized Expert Top Contributor
                    • Feb 2007
                    • 1251

                    #10
                    Originally posted by hirak1984
                    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

                    Comment

                    • bawa
                      New Member
                      • Feb 2007
                      • 8

                      #11
                      Originally posted by AdrianH
                      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

                      Comment

                      Working...