infinite loop detection

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

    infinite loop detection

    i have a program which always run dead after one or two days, i think
    somewhere a piece of the code is suspicious of involving into a
    infinite loop. but for some reason, it is very hard to debug. so i
    thing there might be tool which can statically analysis the code and
    notice me this kind of potential problems if found. any suggestion? (
    i prefer linux open source tools )

    thanks.

    -
    woody

  • Walter Roberson

    #2
    Re: infinite loop detection

    In article <1154923279.591 558.75080@m79g2 000cwm.googlegr oups.com>,
    Steven Woody <narkewoody@gma il.comwrote:
    >i have a program which always run dead after one or two days, i think
    >somewhere a piece of the code is suspicious of involving into a
    >infinite loop. but for some reason, it is very hard to debug. so i
    >thing there might be tool which can statically analysis the code and
    >notice me this kind of potential problems if found. any suggestion? (
    >i prefer linux open source tools )

    --
    Programming is what happens while you're busy making other plans.

    Comment

    • Christopher Benson-Manica

      #3
      Re: infinite loop detection

      Walter Roberson <roberson@ibd.n rc-cnrc.gc.cawrote :
      Steven Woody <narkewoody@gma il.comwrote:
      i have a program which always run dead after one or two days, i think
      somewhere a piece of the code is suspicious of involving into a
      infinite loop. but for some reason, it is very hard to debug. so i
      thing there might be tool which can statically analysis the code and
      notice me this kind of potential problems if found. any suggestion? (
      i prefer linux open source tools )
      1) As Walter pointed out, your problem does not have a general
      solution.

      2) It is possible that there is some open-source code analysis tool
      that may be able to use a heuristic to identify potential bugs, but
      this newsgroup is not the place to ask about it:





      3) Even if you found such a tool, what makes you think that your
      problem is an infinite loop? How do you know that you do not have a
      memory leak, for exmaple?

      4) I'm sure comp.unix.progr ammer would be able to suggest good
      debugging tools and techniques to help you solve your problem.

      --
      C. Benson Manica | I *should* know what I'm talking about - if I
      cbmanica(at)gma il.com | don't, I need to know. Flames welcome.

      Comment

      • Christopher Benson-Manica

        #4
        Re: infinite loop detection

        Steven Woody <narkewoody@gma il.comwrote:

        (Apologies to those who see a duplicate of this message, the original
        was mis-posted as a reply to Walter's post rather than to OP.)
        i have a program which always run dead after one or two days, i think
        somewhere a piece of the code is suspicious of involving into a
        infinite loop. but for some reason, it is very hard to debug. so i
        thing there might be tool which can statically analysis the code and
        notice me this kind of potential problems if found. any suggestion? (
        i prefer linux open source tools )
        1) As Walter pointed out, your problem does not have a general
        solution.

        2) It is possible that there is some open-source code analysis tool
        that may be able to use a heuristic to identify potential bugs, but
        this newsgroup is not the place to ask about it:





        3) Even if you found such a tool, what makes you think that your
        problem is an infinite loop? How do you know that you do not have a
        memory leak, for exmaple?

        4) I'm sure comp.unix.progr ammer would be able to suggest good
        debugging tools and techniques to help you solve your problem.

        --
        C. Benson Manica | I *should* know what I'm talking about - if I
        cbmanica(at)gma il.com | don't, I need to know. Flames welcome.

        --
        C. Benson Manica | I *should* know what I'm talking about - if I
        cbmanica(at)gma il.com | don't, I need to know. Flames welcome.

        Comment

        • Steven Woody

          #5
          Re: infinite loop detection


          Christopher Benson-Manica wrote:
          Walter Roberson <roberson@ibd.n rc-cnrc.gc.cawrote :
          >
          Steven Woody <narkewoody@gma il.comwrote:
          >i have a program which always run dead after one or two days, i think
          >somewhere a piece of the code is suspicious of involving into a
          >infinite loop. but for some reason, it is very hard to debug. so i
          >thing there might be tool which can statically analysis the code and
          >notice me this kind of potential problems if found. any suggestion? (
          >i prefer linux open source tools )
          >
          1) As Walter pointed out, your problem does not have a general
          solution.
          >
          2) It is possible that there is some open-source code analysis tool
          that may be able to use a heuristic to identify potential bugs, but
          this newsgroup is not the place to ask about it:
          >



          >
          3) Even if you found such a tool, what makes you think that your
          problem is an infinite loop? How do you know that you do not have a
          memory leak, for exmaple?
          i am wondering what kind of memory leak can cause halting?
          >
          4) I'm sure comp.unix.progr ammer would be able to suggest good
          debugging tools and techniques to help you solve your problem.
          ok, i will try.
          >
          --
          C. Benson Manica | I *should* know what I'm talking about - if I
          cbmanica(at)gma il.com | don't, I need to know. Flames welcome.

          Comment

          • Walter Roberson

            #6
            Re: infinite loop detection

            In article <1154931014.639 710.171910@75g2 000cwc.googlegr oups.com>,
            Steven Woody <narkewoody@gma il.comwrote:
            >i am wondering what kind of memory leak can cause halting?
            <OT>
            It depends on the operating system and the way it is configured.
            After you run through all the readily available
            memory, the system will usually do one of the following:

            1) Return a NULL pointer for a memory allocation request. If you
            don't check for NULL then there are lots of different behaviours
            that you can run into;

            2) stop your program without warning when it asks for more memory

            3) tell your program it is out of memory, with the telling being done
            in a way that -could- be noticed and dealt with cleanly, but usually
            is not dealt with explicitly with the result being that the program
            stops

            4) stop your program without warning (or with warning as per #3) some
            time -after- it runs through all the available memory, because it
            told you you could have more memory than was really available
            [because it thought you weren't serious about using *all* of it,
            or because it thought that by the time you actually used it, that
            it would have more memory available to give you.]
            (Note: not really using all requested memory is quite common in
            unix-type systems: it happens often when fork() is used.)

            5) And on some systems, as long as you don't allocate more memory
            than a pointer can possibly reference, the operating system will
            continue to give you more and more memory, by allocating disk space
            as if it were system memory. Sometimes this strategy is very
            effective and the result is quite fast, but in other cases
            the strategy results in the computer operating *very* *very* slowly.
            </OT>

            <OT degree="moreso" >
            I've been using Opteron nodes running Debian Linux lately. The nodes
            have 8.5 to 11 gigabytes of RAM. It's pathetically easy to get them
            swapping to the point where they drop input (not just -slow- response:
            they *drop* it even though the buffers are not even close to full.)
            We seldom encounter serious swapping problems on our SGI IRIX machines,
            and the few times we do, the response drops but there -is- still response.
            </OT>
            --
            Is there any thing whereof it may be said, See, this is new? It hath
            been already of old time, which was before us. -- Ecclesiastes

            Comment

            • David Resnick

              #7
              Re: infinite loop detection

              Steven Woody wrote:
              i have a program which always run dead after one or two days, i think
              somewhere a piece of the code is suspicious of involving into a
              infinite loop. but for some reason, it is very hard to debug. so i
              thing there might be tool which can statically analysis the code and
              notice me this kind of potential problems if found. any suggestion? (
              i prefer linux open source tools )
              >
              thanks.
              >
              -
              woody
              So a platform independant answer is that you could add some more
              logging (fprintfs/whatever you are using) so you know where your
              program is and what it is doing once it fails by whatever means it
              fails -- which not too clear to me. Do you mean by infinite loop that
              it is spinning, burning CPU, but not using other resources in an
              increasing way that would cause the system to run out of memory/etc?

              Or ask in comp.unix.progr ammer or a linux group. Someone can probably
              direct you at a way to, e.g., attach a debugger to your program and see
              what it is currently executing (assuming by "dead" you mean up but not
              responsive/etc) or making it dump a core and analyze it/etc.

              -David

              Comment

              • inmatarian

                #8
                Re: infinite loop detection

                Steven Woody wrote:
                i have a program which always run dead after one or two days, i think
                somewhere a piece of the code is suspicious of involving into a
                infinite loop. but for some reason, it is very hard to debug. so i
                thing there might be tool which can statically analysis the code and
                notice me this kind of potential problems if found. any suggestion? (
                i prefer linux open source tools )
                >
                thanks.
                >
                -
                woody
                >
                If you can alter the code in question, where you think infinite loops
                are happening, add an extra terminating condition. Or, if that's not an
                option, start some kind of timer based callback, or even a thread,
                which'll monitor the program and tell you where it's running dead.

                Inmatarian.

                Comment

                • Steven Woody

                  #9
                  Re: infinite loop detection

                  inmatarian wrote:
                  Steven Woody wrote:
                  i have a program which always run dead after one or two days, i think
                  somewhere a piece of the code is suspicious of involving into a
                  infinite loop. but for some reason, it is very hard to debug. so i
                  thing there might be tool which can statically analysis the code and
                  notice me this kind of potential problems if found. any suggestion? (
                  i prefer linux open source tools )

                  thanks.

                  -
                  woody
                  >
                  If you can alter the code in question, where you think infinite loops
                  are happening, add an extra terminating condition. Or, if that's not an
                  option, start some kind of timer based callback, or even a thread,
                  which'll monitor the program and tell you where it's running dead.
                  >
                  Inmatarian.
                  thank you all. actually, the program was written in linux and
                  cross-compliled before running in a microcontroller where there is no
                  extra serial port to print out debug info. any invalid point reference
                  in the platform will cause a reboot rather halt, this leads me think
                  the problem is a infinite loop. another thing is that i only use few of
                  malloc operations that is not likely be the cause.

                  Comment

                  • Flash Gordon

                    #10
                    Re: infinite loop detection

                    Steven Woody wrote:
                    inmatarian wrote:
                    >Steven Woody wrote:
                    >>i have a program which always run dead after one or two days, i think
                    >>somewhere a piece of the code is suspicious of involving into a
                    >>infinite loop. but for some reason, it is very hard to debug. so i
                    >>thing there might be tool which can statically analysis the code and
                    >>notice me this kind of potential problems if found. any suggestion? (
                    >>i prefer linux open source tools )
                    >>>
                    >>thanks.
                    >>>
                    >>-
                    >>woody
                    >>>
                    >If you can alter the code in question, where you think infinite loops
                    >are happening, add an extra terminating condition. Or, if that's not an
                    >option, start some kind of timer based callback, or even a thread,
                    >which'll monitor the program and tell you where it's running dead.
                    >>
                    >Inmatarian.
                    >
                    thank you all. actually, the program was written in linux and
                    cross-compliled before running in a microcontroller where there is no
                    extra serial port to print out debug info.
                    Hook up an in-circuit emulator. Or a logic analyser. Or get the program
                    to change the state of a couple of pins depending on what it is doing
                    and hook up an oscilloscope. Or write harnesses to allow you to run the
                    code on some other system such as your PC. I've used all of these methods.
                    any invalid point reference
                    in the platform will cause a reboot rather halt,
                    It could be going in to a reboot loop.
                    this leads me think
                    the problem is a infinite loop.
                    You will have to find some method to identify where the code is failing.
                    Identifying if there are infinite loops is, in general, not possible by
                    static analysis.
                    another thing is that i only use few of
                    malloc operations that is not likely be the cause.
                    It only takes one memory corruption (by overrunning a buffer for
                    example) for the next call to malloc to potentially crash in some manner.

                    Until you either identify where the code is crashing or manage to
                    *prove* that some areas are not the problem area, the problem could be
                    anywhere and caused by any form of undefined error or by some logic
                    error in your code.
                    --
                    Flash Gordon
                    Still sigless on this computer.

                    Comment

                    • pete

                      #11
                      Re: infinite loop detection

                      Steven Woody wrote:
                      >
                      i have a program which always run dead after one or two days,
                      The cpu is overheating.

                      --
                      pete

                      Comment

                      Working...