detect infinite loop in c program

This is a discussion on detect infinite loop in c program within the C Programming forums, part of the General Programming Boards category; >>i am terribly disappointed Get over it Maybe this has something: http://www.splint.org/...

  1. #16
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>i am terribly disappointed
    Get over it

    Maybe this has something:
    http://www.splint.org/
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  2. #17
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    there probably isn't a way to determine if it loops forever other than looking for things like
    while(true)
    for(;; )

    or writing an ASM parser looking for a CONDITION in a loop, other than that, have fun

    -LC
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  3. #18
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    > i agree with u frnd that it was proved that its unsolvable in 1936.. but there are things that have been chg later..
    Well mathematical proofs tend to stand for all time - I don't see any need to worry about how long ago it was. I don't for example worry that pythagoras' theorem a*a + b*b = c*c will be dis-proved in any near future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #19
    Registered User
    Join Date
    Sep 2003
    Posts
    6
    FYI
    I can tell some of the mathematical proofs which are lying in dust and they were considered words of GOD one time.. nyways thats not my purpose ... i was looking for a solution rather than tryin ppl knowlege of maths ... and u may call it bad but if i cant solve a problem , i get disappointed.....

    looks like i have to write a parser where i will look for possible loops, iknow it wont be one covering all the cases but it wil do for the time being..
    till then if someone can think of ny better sol. i will appreciate....

  5. #20
    Rog
    Rog is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    One possible solution would be to have a reasonable time of execution/completion. The detector program would need to launch the program to be tested and continue to run concurrently. The detector would wait for the test program to return. While the test program executes, the detector uses the standard library function difftime() to compare the execution time of the test program to the reasonable time. If the test program does not return before the reasonable time is exceded the program is in an infinate loop.

    This algorithm will only work for a specific input, but we know from Alan Turing's work that a solution that works for all inputs in not possible.

    Rog

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  3. Why does the loop in my program turn infinite?
    By DaniiChris in forum C Programming
    Replies: 6
    Last Post: 07-08-2008, 02:44 AM
  4. How to detect another program installing?
    By HyperCreep in forum Windows Programming
    Replies: 7
    Last Post: 10-29-2007, 09:02 AM
  5. Program stuck in infinite loop-->PLEASE HELP
    By Jedijacob in forum C Programming
    Replies: 5
    Last Post: 03-26-2005, 11:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21