473,701 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7645
In article <11************ *********@m79g2 000cwm.googlegr oups.com>,
Steven Woody <na********@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 )
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.n rc-cnrc.gc.cawrote :
Steven Woody <na********@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:

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.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.
Aug 7 '06 #3
Steven Woody <na********@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:

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

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

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.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.
Aug 7 '06 #5
In article <11************ **********@75g2 000cwc.googlegr oups.com>,
Steven Woody <na********@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
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.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

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

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

Similar topics

43
5581
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 fallacy built on the assumption of mythical infinite all powerfull machines. In reality we deal with finite machines that are capable of two states in a loop, they either terminate, or repeat themselves. In the mythical halting problem scenario...
5
4945
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
2346
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 replicated back to source table A (true bi-directional replication scenario). Once I start replication on a master to master scenario the changes in A gets replicated to B but that change gets replicated back to A and so on creating an infinite loop. Is...
44
4320
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
2452
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 rather than loading the page the browser goes into some kind of infinit loop if(navigator.userAgent.indexOf("Firefox") != -1) { window.location = "ff_enquiries.html";
1
8978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8936
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7827
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5905
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4411
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3104
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2036
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.