Stack overflows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daz

    Stack overflows

    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

  • Phlip

    #2
    Re: Stack overflows

    Daz wrote:
    [color=blue]
    > 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.[/color]

    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!!!


    Comment

    • Daz

      #3
      Re: Stack overflows


      Phlip wrote:[color=blue]
      > 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.[/color]

      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.

      Comment

      • Ian Collins

        #4
        Re: Stack overflows

        Daz wrote:[color=blue]
        >
        > 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.
        >[/color]
        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.

        Comment

        • Steve Pope

          #5
          Re: Stack overflows

          Phlip <phlipcpp@yahoo .com> wrote:
          [color=blue]
          >Daz wrote:[/color]
          [color=blue][color=green]
          >> 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?[/color][/color]
          [color=blue]
          >You have been posting here long enough to notice all the screams over
          >off-topic questions, right?[/color]
          [color=blue]
          >The limit of your stack is implementation-defined, and the behavior when you
          >overflow it is either implementation-defined or undefined.[/color]
          [color=blue]
          >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.[/color]

          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

          Comment

          • Howard

            #6
            Re: Stack overflows


            "Steve Pope" <spope33@speedy mail.org> wrote in message
            news:e7afcm$hci $1@blue.rahul.n et...
            [color=blue]
            >
            > 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.
            >[/color]

            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




            Comment

            • Steve Pope

              #7
              Re: Stack overflows

              Howard <alicebt@hotmai l.com> wrote:
              [color=blue]
              >"Steve Pope" <spope33@speedy mail.org> wrote in message[/color]
              [color=blue][color=green]
              >> 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.[/color][/color]
              [color=blue]
              >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.[/color]

              Thanks, that makes more sense.

              Steve

              Comment

              Working...