473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Aug 7 '06 #1
10 7606
In article <11*********************@m79g2000cwm.googlegroups. com>,
Steven Woody <na********@gmail.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 )
http://en.wikipedia.org/wiki/Halting_problem
--
Programming is what happens while you're busy making other plans.
Aug 7 '06 #2
Walter Roberson <ro******@ibd.nrc-cnrc.gc.cawrote:
Steven Woody <na********@gmail.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:

http://www.ungerhu.com/jxh/clc.welcome.txt
http://c-faq.com
http://benpfaff.org/writings/clc/off-topic.html

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.programmer 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)gmail.com | don't, I need to know. Flames welcome.
Aug 7 '06 #3
Steven Woody <na********@gmail.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:

http://www.ungerhu.com/jxh/clc.welcome.txt
http://c-faq.com
http://benpfaff.org/writings/clc/off-topic.html

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.programmer 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)gmail.com | don't, I need to know. Flames welcome.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Aug 7 '06 #4

Christopher Benson-Manica wrote:
Walter Roberson <ro******@ibd.nrc-cnrc.gc.cawrote:
Steven Woody <na********@gmail.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:

http://www.ungerhu.com/jxh/clc.welcome.txt
http://c-faq.com
http://benpfaff.org/writings/clc/off-topic.html
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.programmer 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)gmail.com | don't, I need to know. Flames welcome.
Aug 7 '06 #5
In article <11**********************@75g2000cwc.googlegroups. com>,
Steven Woody <na********@gmail.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
Aug 7 '06 #6
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.programmer 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

Aug 7 '06 #7
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.
Aug 8 '06 #8
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.

Aug 9 '06 #9
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.
Aug 9 '06 #10
Steven Woody wrote:
>
i have a program which always run dead after one or two days,
The cpu is overheating.

--
pete
Aug 10 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
5
by: mailpitches | last post by:
Hello, Is there any way to kill a Javascript infinite loop in Safari without force-quitting the browser? MP
6
by: RdR | last post by:
Hi, Has anyone encountered infinite looping in Q Replication? This happens when I have a source DB2 table A going to a target DB2 table B, it also happens that the samne target table B is...
44
by: James Watt | last post by:
can anyone tell me how to do an infinite loop in C/C++, please ? this is not a homework question .
9
by: Max58kl | last post by:
Hi I am trying to use browser detection to load browser specific web pages. The first part always seems to work ok, the Firefox page loads correctly. Everytime I try to load the page in IE7...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.