Help with debugging code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pauldepstein@att.net

    #1

    Help with debugging code

    I am writing code to price some financial options using recursive
    functions.

    It compiles but I get a runtime error which is caused by a memory
    violation.

    The problem is that the code is much too long to be suitable for
    inclusion in this posting, and I don't know where the problem lies.

    If anyone does have the time/willingness/extreme kindness to help me, I
    would think that the simplest thing would be for them to get in touch
    with me at pauldepstein@ya hoo.com

    I can be reached by yahoo IM also. My yahoo ID is pauldepstein.

    If anyone feels they could help me but only on a paid basis, please let
    me know and we'll try and work something out.

    Thank you,

    Paul Epstein

  • pauldepstein@att.net

    #2
    Re: Help with debugging code


    pauldepst...@at t.net wrote:[color=blue]
    > I am writing code to price some financial options using recursive
    > functions.
    >
    > It compiles but I get a runtime error which is caused by a memory
    > violation.
    >
    > The problem is that the code is much too long to be suitable for
    > inclusion in this posting, and I don't know where the problem lies.
    >
    > If anyone does have the time/willingness/extreme kindness to help me, I
    > would think that the simplest thing would be for them to get in touch
    > with me at pauldepstein@ya hoo.com
    >
    > I can be reached by yahoo IM also. My yahoo ID is pauldepstein.
    >
    > If anyone feels they could help me but only on a paid basis, please let
    > me know and we'll try and work something out.
    >
    > Thank you,
    >
    > Paul Epstein[/color]

    Sorry. On rereading the above posting, I see that readers would have
    to go through an unnecessary second process to obtain my email address.

    My email address is pauldepstein at yahoo dot com

    Thanks again for your help and support.

    Paul Epstein

    Comment

    • mlimber

      #3
      Re: Help with debugging code

      pauldepst...@at t.net wrote:[color=blue]
      > I am writing code to price some financial options using recursive
      > functions.
      >
      > It compiles but I get a runtime error which is caused by a memory
      > violation.
      >
      > The problem is that the code is much too long to be suitable for
      > inclusion in this posting, and I don't know where the problem lies.
      >
      > If anyone does have the time/willingness/extreme kindness to help me, I
      > would think that the simplest thing would be for them to get in touch
      > with me at pauldepstein@ya hoo.com
      >
      > I can be reached by yahoo IM also. My yahoo ID is pauldepstein.
      >
      > If anyone feels they could help me but only on a paid basis, please let
      > me know and we'll try and work something out.
      >
      > Thank you,
      >
      > Paul Epstein[/color]

      Have you run through the program in your debugger? Can you boil it down
      to a simple but complete example that demonstrates the same problem?
      See this FAQ on posting code:



      Wild guess: you're overflowing your stack because of repeated
      recursion. Try enlarging the stack size (perhaps in the project
      settings if you're using an IDE, or maybe via a command line tool in
      some flavor of unix).

      Cheers! --M

      Comment

      • pauldepstein@att.net

        #4
        Re: Help with debugging code


        mlimber wrote:[color=blue]
        > pauldepst...@at t.net wrote:[color=green]
        > > I am writing code to price some financial options using recursive
        > > functions.
        > >
        > > It compiles but I get a runtime error which is caused by a memory
        > > violation.
        > >
        > > The problem is that the code is much too long to be suitable for
        > > inclusion in this posting, and I don't know where the problem lies.
        > >
        > > If anyone does have the time/willingness/extreme kindness to help me, I
        > > would think that the simplest thing would be for them to get in touch
        > > with me at pauldepstein@ya hoo.com
        > >
        > > I can be reached by yahoo IM also. My yahoo ID is pauldepstein.
        > >
        > > If anyone feels they could help me but only on a paid basis, please let
        > > me know and we'll try and work something out.
        > >
        > > Thank you,
        > >
        > > Paul Epstein[/color]
        >
        > Have you run through the program in your debugger? Can you boil it down
        > to a simple but complete example that demonstrates the same problem?
        > See this FAQ on posting code:
        >
        > http://parashift.com/c++-faq-lite/ho...t.html#faq-5.8
        >
        > Wild guess: you're overflowing your stack because of repeated
        > recursion. Try enlarging the stack size (perhaps in the project
        > settings if you're using an IDE, or maybe via a command line tool in
        > some flavor of unix).
        >
        > Cheers! --M[/color]

        Thank you, M limber!

        I think your "wild guess" is probably correct. Here is more info on
        the code: I set a variable J using a function which is a member of the
        parameters class.

        I then access J in several places and inside recursive functions using
        the line: int J = params_ptr->get_int("J") ;

        if (!strncmp (in_string, "J", 100)) {return J; } is part of the
        get_int function.

        This accessing of J seems to work going through the loop a few times
        but not on the sixth.

        So your "guess" is very helpful.

        I am very much a newbie and have no idea how to enlarge the stack size.

        The IDE is dev c++. Of course, I would be happy to research the topic
        of stack-size-enlarging-using-Dev-c++ independently. (I will google it
        immediately after this posting.) I merely mention my ignorance of
        this, by way of reply to your advice.

        Thank you,

        Paul Epstein

        Comment

        • Ben Pope

          #5
          Re: Help with debugging code

          mlimber wrote:[color=blue]
          > pauldepst...@at t.net wrote:[color=green]
          >> I am writing code to price some financial options using recursive
          >> functions.
          >>
          >> It compiles but I get a runtime error which is caused by a memory
          >> violation.[/color][/color]

          <snip>
          [color=blue]
          > Wild guess: you're overflowing your stack because of repeated
          > recursion. Try enlarging the stack size (perhaps in the project
          > settings if you're using an IDE, or maybe via a command line tool in
          > some flavor of unix).[/color]

          ....and of course, make sure that the recursion is bounded!

          We should be able to see what's wrong by seeing the declaration of the
          recursive function, the initial values passed to it, and anything inside
          the function that modifies any of the values passed to it.

          Ben Pope
          --
          I'm not just a number. To many, I'm known as a string...

          Comment

          Working...