Slashdot Mirror


Escaping Infinite Loops

twocentplain writes in with an MIT news release about Jolt, a research project designed to unfreeze software stuck in an infinite loop (for a subset of infinite loops). It uses a combination of static instrumentation (using LLVM) and a run time watchdog that checks the program state during loop iteration; when a duplicate state is detected it permits the user to take one a few actions to escape the loop. The authors claim it works well enough that the program can often continue operating properly. The original paper contains detailed case studies.

204 comments

  1. yipes by Anonymous Coward · · Score: 2, Insightful

    bad programmers can now sink to new lows...

    1. Re:yipes by Alien+Being · · Score: 1

      Yes and no. Once the infinite loop had been detected, it can also be reported and characterized.

      Granted, it's no insurance policy against a faulty mission-control system on an airplane or in a nuclear facility, but it does represent an interesting facet of quality control.

    2. Re:yipes by KiloByte · · Score: 1

      Yeah, it's no different from ON ERROR RESUME NEXT, with the added benefit of adding a cost to correct programs.

      They'd have to save the state of the whole machine on every watchdog tick. Hashing the whole memory is out of question, you'd need to hash just pages written to since the last tick, and that requires setting up page faults on the rest (or some custom architecture with generational memory, also costly).

      Plus, there's absolutely no way to resume from such a loop when you detect it and still have the program's state be useful. The resume code would need to solve an uncomputable problem if it's supposed to be generic -- and if it's not, you can just as well not have the infinite loop bug in the first place.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    3. Re:yipes by Anonymous Coward · · Score: 0

      When I was lad this is what the ESC key did.

    4. Re:yipes by Unknown+Lamer · · Score: 1

      They'd have to save the state of the whole machine on every watchdog tick. Hashing the whole memory is out of question, you'd need to hash just pages written to since the last tick, and that requires setting up page faults on the rest (or some custom architecture with generational memory, also costly).

      Actually, the authors extend LLVM and statically instrument code so they only incur overhead when actually checking for infinite loops, and it is fairly lightweight since it can take advantage of this static knowledge to only record the state that is relevant to the loop continuing or exiting..

      --

      HAL 7000, fewer features than the HAL 9000, but just as homicidal!
  2. Loop invariants by Anonymous Coward · · Score: 4, Insightful

    So you just jump to an address outside of the loop and hope that your loop invariant hasn't been violated?

    1. Re:Loop invariants by YodasEvilTwin · · Score: 1

      My thought exactly. Not to mention that other operations performed by the loop (that are obviously malfunctioning) may be necessary for the program to proceed correctly even if they don't affect the loop invariant.

    2. Re:Loop invariants by ShakaUVM · · Score: 1

      >>My thought exactly. Not to mention that other operations performed by the loop (that are obviously malfunctioning) may be necessary for the program to proceed correctly even if they don't affect the loop invariant.

      I guess MAYBE if you write code defensively throughout your codebase, it might work. Though it seems a recipe for disaster unless it'd be a worse disaster for your code to freeze up. (Medical equipment, maybe? Yikes.) But programmers that are cautious to validate all their input and output are also going to be not writing loops that fall into infinite loops.

      I've actually been bitten in the ass by watchdog timers before. No, I'm not in an infinite loop, thank you very much, I'm just running a complicated calculation. It sounds like this will be a little bit more sophisticated, maybe.

    3. Re:Loop invariants by neokushan · · Score: 1

      Don't your average, bog-standard windows programs run in an infinite loop? Does this account for that?

      --
      +1 IDisagreeSoHeMustBeATrollOrAnAstroturferOrAShill
    4. Re:Loop invariants by Anonymous Coward · · Score: 0

      No, it is not an infinite loop. It is, generally, a loop built around a blocking function that will return true as long as the message queue does not have a quit message posted to it, e.g.

      MSG msg;
      while(GetMessage(&msg))
      {
          DispatchMessage(msg);
      }

      It's not really that different from blocking network operations in that respect.

    5. Re:Loop invariants by angel'o'sphere · · Score: 1

      The loop invariant (assuming you know what it is) is not the state of your program, but only the state of your loop!

      If after several loops the state of the program is not changing, the loop obviously is not doing anything and is an endless loop ... well that was simple, don't get how you failed to see that.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    6. Re:Loop invariants by CSMoran · · Score: 1

      Though it seems a recipe for disaster unless it'd be a worse disaster for your code to freeze up. (Medical equipment, maybe? Yikes.)

      I'd rather never choose between "the irradiator control is stuck in a for(;;) loop" and "let's get out of the irradiator control loop by using a default radiation of 99999.99999".

      --
      Every end has half a stick.
    7. Re:Loop invariants by Anonymous Coward · · Score: 0

      That is just one case of loops. What about the far more likely case of the program state changing after every iteration?

    8. Re:Loop invariants by F.Ultra · · Score: 1

      Not necessarily, say that your loop is the inside to strchr(), then your loop invariant is your return value and it will not point to a nice place in memory after having looped over a 64-bit space for a few hours or what the threshold of this technology is.

    9. Re:Loop invariants by BasharTeg · · Score: 1

      No, as you can see from the following, the standard Win32 message pump isn't an infinite loop...

      while(GetMessage(&Msg, NULL, 0, 0) > 0)
      {
              TranslateMessage(&Msg);
              DispatchMessage(&Msg);
      }

    10. Re:Loop invariants by FrankieBaby1986 · · Score: 2

      I think it's a bit more complicated than that. If the loop were polling a device or address or something outside of the state of the program, the loop very well could be 'infinite' by that definition, but not malfunctioning.

      --
      ERROR: SIG NOT FOUND (A)bort, (R)etry, (F)ail?:
    11. Re:Loop invariants by sourcerror · · Score: 1

      Just put a monad on that loop :)

    12. Re:Loop invariants by arth1 · · Score: 1

      If after several loops the state of the program is not changing, the loop obviously is not doing anything and is an endless loop ...

      This is a false assumption. It may be reading a hardware value that hasn't changed yet - the state of the program will be the same.
      Or it might be running a loop that should run forever with the same state in normal conditions. Like a watchdog.

    13. Re:Loop invariants by ShakaUVM · · Score: 1

      >>I'd rather never choose between "the irradiator control is stuck in a for(;;) loop" and "let's get out of the irradiator control loop by using a default radiation of 99999.99999".

      Right (hence my "yikes"). But if you're in a failstop engineered system, you don't want your code falling into an infinite loop while the radiation gun is on... probably the right way to do it would be to have the Jolt thing throw an exception which the code could trap and safely shut everything down instead of just blithely continuing to execute the code.

      But nothing is an excuse for not writing code that doesn't fall into an infinite loop in the first place.

    14. Re:Loop invariants by Anonymous Coward · · Score: 0

      Actually, no. We sleep while we wait for events to fire that our program subscribes to. i.e. almost 0% cpu usage.

    15. Re:Loop invariants by angel'o'sphere · · Score: 1

      True ofc, thats why the article said: for most loops.

      And a typical program, those programs we talk about, like Word etc. dont have a Watchdog build in nor do they read hardware values. That was the point of the article.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    16. Re:Loop invariants by angel'o'sphere · · Score: 1

      That is true, but programs like Word etc. don't do that. Hence the idea of the article ... I also more or less ment to answer to the "silly loop invariant" post before ;D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    17. Re:Loop invariants by angel'o'sphere · · Score: 1

      I would assume that you could check the registers as well. However your point is good. Perhaps you would need to recognize "libraries" and exclude them, pretending they where proven to be good.
      OTOH with our days "random" loading of libs it is perhaps not really possible.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    18. Re:Loop invariants by petermgreen · · Score: 1

      For something like a medical radiation source I think you would have a hardware watchdog timer. If the control hardware doesn't get an update after a set time interval then it assumes the system has crashed and shuts off.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    19. Re:Loop invariants by Anonymous Coward · · Score: 0

      Yes, but the state of the program should be changing on each iteration, so it wouldn't be detected as an infinite loop. Also, the example given in another comment should be checking for WM_QUIT and not > 0.

  3. The authors claim... by Nikker · · Score: 2

    The authors claim it works well enough that the program can often continue operating properly.

    If the software wasn't written properly to begin with, what metric are we now using to establish it is operating "properly" ?

    --
    A loop, by its nature, continues. If that didn't make sense, start reading this sentence again.
    1. Re:The authors claim... by Anonymous Coward · · Score: 0

      What I've seen people do for a long time "if it doesn't crash it's fine".

    2. Re:The authors claim... by drpimp · · Score: 1

      Not to mention that if you just jump out of the loop, the software state is probably (in most cases) invalid anyhow. Not that you are any worse off then just leaving it hung, but killing the process will most likely still be required unless it's a well written threaded app of sorts, but we probably wouldn't be having this discussion if that was the case now anyway right?

      --
      -- Brought to you by Carl's JR
    3. Re:The authors claim... by cowboy76Spain · · Score: 1

      Yeah, but "restoring" your program in an indefinite state may have worse consequencies than just freezing. Imagine that your compression algorithm has an infinite loop in certains conditions and, when the data has been "successfully" processed, it is written to your file...

      --
      Why can't /. have a rich-text editor? Editing your own HTML is so XXth century.
    4. Re:The authors claim... by Charliemopps · · Score: 1

      It does the thing you made it to do in the amount of time you want it to do it.

    5. Re:The authors claim... by Hatta · · Score: 1

      Isn't it impossible to determine a priori whether a given piece of software will halt? How can you then say that any software that doesn't halt isn't acting properly?

      --
      Give me Classic Slashdot or give me death!
    6. Re:The authors claim... by newcastlejon · · Score: 2

      IANACS, but this seems different to the halting problem: if the program is a FSM (not the Noodly One) then one that repeatedly enters the same state with a short period is possibly in an infinite loop. The halting problem is more a question of being able to tell if a program given an input ever reaches its end without actually running it

      --
      If God forks the Universe every time you roll a die, he'd better have a damned good memory.
    7. Re:The authors claim... by bondsbw · · Score: 1

      Not really. Running the program/input in question is an option, so long as the executing environment itself always halts. It must somehow detect that the program/input in question does not halt, but then halt itself while returning that fact.

      The undecidable nature of the halting problem indicates that there is no executing environment for which this is true for all possible programs and inputs.

      This software appears to be able to answer that question for some programs and inputs.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    8. Re:The authors claim... by Urkki · · Score: 1

      Not to mention that if you just jump out of the loop, the software state is probably (in most cases) invalid anyhow.

      These days many programs are event based. I'd say there's a decent chance, that program is left in valid state, especially if loop is broken at the condition, and remaining code in the function is allowed to execute before function returns to the main event loop.

    9. Re:The authors claim... by dgatwood · · Score: 1

      Either it is taking in new data, in which case you will never reach an exact repeated state, or it isn't, in which case the programmer was incompetently using polling instead of a more reasonable notification mechanism, and you should buy or write better software.

      Besides, for most graphical applications, a hang means an infinite loop in the main run loop. Kicking the app back out to the main run loop should almost never cause any catastrophic side effects, and will usually leave the app in a state that is clean enough to allow you to perform a "Save As" operation before quitting.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    10. Re:The authors claim... by kyrsjo · · Score: 1

      This is what happens if you raise an exception in a pyGTK program.

    11. Re:The authors claim... by F.Ultra · · Score: 2

      It could however open up new security holes. What today is a simple DOS (sending a packet that makes your software loop for ever) could now possible be turned into an exploit since the loop is terminated with whatever status it has now (which the attacker knows since he can play with the same software).

    12. Re:The authors claim... by sjames · · Score: 1

      Actually, you could be in a much worse condition. With it hung, you don't then end up working with it's invalid output. If you let it continue it might return "SUCCESS" and cause further processing on garbage output.

    13. Re:The authors claim... by IICV · · Score: 2

      The halting problem is more a question of being able to tell if a program given an input ever reaches its end without actually running it

      Nope, that is incorrect. The Halting Problem is being able to tell if an arbitrary program will ever halt on a given input, even if you are allowed to run it. That's what makes it tricky, because even if you run a program for X time and it doesn't terminate, maybe you just didn't run it long enough - maybe if you run it for 2X time, it will terminate.

      The thing is, the thing a lot of CS people don't know or forget, is that a lot of the time when we say something is hard or impossible, what we're really saying is "there exists at least one case for which this is hard or impossible".

      So, you know, Travelling Salesman? Not that hard, if there's only a hundred nodes or so. Especially if it's the subset of the TSP we see in reality; in real life, moving a little bit east will put you a little bit closer to everything in the east, which is not true at all in the general TSP.

      Halting Problem? Totally doable, on a lot of the programs you're likely to see out in the real world; after all, they're all supposed to terminate. It's not like people write programs that loop trickily on purpose specifically to confuse halting problem solving programs. A well written halting problem program could probably catch like 80-90% of unintentional infinite loops.

    14. Re:The authors claim... by Urkki · · Score: 1

      Well, I don't think this would ever be used with network application, nobody sensibl... ok yeah.

      But indeed, there are security implications for desktop applications that load documents, too. A document which previously caused the application to just hang or "safely" crash, could now cause malicious code to be executed.

  4. Easy... by xMrFishx · · Score: 1

    I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

    1. Re:Easy... by Baloroth · · Score: 4, Funny

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      --
      "None can love freedom heartily, but good men; the rest love not freedom, but license." --John Milton
    2. Re:Easy... by Anonymous Coward · · Score: 1

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

    3. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought recursion wasn't the same as looping. For one thing, real machines have finite stack space. (But, tail recursion, blah, blah. Except you quoted him...)

    4. Re:Easy... by Anonymous Coward · · Score: 1

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

    5. Re:Easy... by gl4ss · · Score: 2

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      this is the infinite loop watch-- yo dawg, it seems you like repeating so we put an infinite loop in your infinite loop.

      --
      world was created 5 seconds before this post as it is.
    6. Re:Easy... by Short+Circuit · · Score: 1

      Any recursive function can be converted to a loop, and vice versa. Of course, any real machine will have a finite heap, so you wouldn't be able to properly emulate a machine with an infinite stack. (Which would be the analogous counterpart to your implied infinite heap, if we include the constraints in a transformation)

    7. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

    8. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      Execution timer expired; exiting.

    9. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

    10. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      ...

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      Stack overflow

    11. Re:Easy... by ObsessiveMathsFreak · · Score: 2

      Mother of God.... It's FORKING!!!

      --
      May the Maths Be with you!
    12. Re:Easy... by demars · · Score: 1

      Thanks. I'll bet they never thought of that!

    13. Re:Easy... by awshidahak · · Score: 1

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

    14. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

      Uh, I mean, reactive is better than no active at all.

    15. Re:Easy... by psithurism · · Score: 1

      Yeah, I like not programming infinite loops, and I often add my own reactive fixes if I suspect there is a small possibility of infinite loops occurring.

      It's all those other programmers who disagree with us that this is good for; I could really use a tool to kick their libraries and applications back into a running state.

    16. Re:Easy... by Anonymous Coward · · Score: 0

      I always thought the best method of getting out of infinite loops was to not have infinite loops. Everybody loves watchdogs and timers but they would be a reactive fix rather than a proactive fix.

  5. Bad idea by Anonymous Coward · · Score: 0

    Compensating for failure to design properly at the compiler level scares me.

  6. Does This Really Happen? by Anonymous Coward · · Score: 0

    Sure, I've written infinite loops, and encountered them while debugging. But how often do you actually find infinite loops (that you KNOW are infinite loops) in software that's actually been released?

    1. Re:Does This Really Happen? by UnknowingFool · · Score: 2

      You mean like the Zune Leap Year Bug which causes them to be unusable for a few days?

      --
      Well, there's spam egg sausage and spam, that's not got much spam in it.
    2. Re:Does This Really Happen? by Short+Circuit · · Score: 1

      In my own code, even.

    3. Re:Does This Really Happen? by dgatwood · · Score: 1

      But how often do you actually find infinite loops (that you KNOW are infinite loops) in software that's actually been released?

      I found one in a shipping version of Xcode 4 last week. Steps to reproduce:

      1. Create a project containing a library.

      2. Drag the library into its own "Link Binary With Libraries" box.

      3. Build.

      It's not as uncommon as you think when you're dealing with apps that maintain complex, potentially cyclic (or at least heavily cross-linked) data structures under the hood.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    4. Re:Does This Really Happen? by psithurism · · Score: 1

      how often do you actually find infinite loops (that you KNOW are infinite loops) in software that's actually been released?

      Never, because I can't be sure. Though, when a program freezes up (happens almost daily to me) and one of my CPUs jumps to 100% usage and sits there for a few minutes, I get suspicious. I've never put any other structures that do that in my code (besides near infinite loops), so I am forced to assume: infinite loops.

  7. Infinite loops aren't the real problem by grimmjeeper · · Score: 1

    I've found that tasks waiting on resources without a reasonable timeout (or sometimes no timeout at all) and refusing to respond to outside stimuli are more often the problem than a task stuck in an infinite loop.

    1. Re:Infinite loops aren't the real problem by sdBlue · · Score: 2

      One might argue that the function that is waiting on the resource with no timeout is itself an infinite loop (as to whether or not this fix would fix that, it would of course depend on error checking code being present and correct, after the loop exits...)

    2. Re:Infinite loops aren't the real problem by grimmjeeper · · Score: 1

      Good point. A task forever stuck in a wait state pending on a resource allocation would resemble an infinite loop. Though a task that's stuck in the pending queue by the scheduler may not ever show up as an infinite loop since it doesn't actually get scheduled to run anything. I wonder how a task like that would be handled differently than one with an actual infinite loop.

    3. Re:Infinite loops aren't the real problem by Anonymous Coward · · Score: 0

      A thread in a waiting or blocked state is a normal condition and in no way resembles an infinite loop, since no code is being executed as the OS will not schedule it to run until it becomes runnable

  8. Really interesting by Harald+Paulsen · · Score: 3, Funny

    That's really interesting.
    That's really interesting.
    That's really interesting.
    That's really interesting.
    That's really interesting.
    # duplicate state detected, jumping loop
    Daisy, daisy, give me your answer do..

    --
    Harald
    1. Re:Really interesting by grimmjeeper · · Score: 2

      I'm sorry Dave. I'm afraid I just can't do that.

    2. Re:Really interesting by Z_A_Commando · · Score: 1

      Ah, ah, ah, you didn't say the magic word!

    3. Re:Really interesting by Anonymous Coward · · Score: 0

      "I hate this hacker crap"...

      "Ah, ah, ah?"
      "Ah, ah, ah?"
      "Ah, ah, ah?"
      "Ah, ah, ah?"
      "Ah, ah, ah?"
      "Ah, ah, ah?"...

      -AC

    4. Re:Really interesting by stderr_dk · · Score: 1

      It's a UNIX system! I know this!

      --
      alias sudo="echo make it yourself #" ; # https://pipedot.org/~stderr & http://soylentnews.org/~stderr
    5. Re:Really interesting by hpa · · Score: 1

      Squeamish Ossifrage.

    6. Re:Really interesting by Anonymous Coward · · Score: 1

      What's more disturbing? These geek references, the fact that I understood them, or both?

    7. Re:Really interesting by canajin56 · · Score: 1

      Clever girl.

      --
      ASCII stupid question, get a stupid ANSI
    8. Re:Really interesting by Anonymous Coward · · Score: 1

      Misquote. HAL never said "just".

    9. Re:Really interesting by Anonymous Coward · · Score: 0

      Prior art.

      • Jon Skeet can stop an infinite loop just by thinking about it
  9. Interesting.... what about finite state machines? by Anonymous Coward · · Score: 0

    This is an interesting, and no doubt fairly useful piece of software, but, now, correct me if I'm wrong - if a program is coded as a finite state machine there'd be instances of duplicate states that can appear to be "hung," in which case this software would only do harm, no?

  10. Halting Problem by krovisser · · Score: 4, Funny

    So we've solved the halting problem.

    By making it the user's problem?

    Wait a second...

    1. Re:Halting Problem by gstrickler · · Score: 1

      Isn't that the standard reply from developers and tech support?

      --
      make imaginary.friends COUNT=100 VISIBLE=false
    2. Re:Halting Problem by AdmiralXyz · · Score: 4, Interesting

      Joking aside, this really has nothing to do with the Halting Problem, because the Halting Problem is a statement about Turing machines, which have unbounded space. Actual computers are not Turing machines: because they have finite memory, they have a finite (though very large) number of states, and are actually finite-state automata.

      Here, the Halting Problem doesn't really apply, because if all else fails, you can (in theory) take every combination of programs up to N bits in length, and every combination of inputs up to M bits in length, and make a table of size 2^(N + M) saying whether a given program halts on a given input by running it and looking for a duplicate state. Of course that's impossible in the real world, but it does demonstrate that there's nothing about this research that's violating established principles of computer science.

      And in a sense, that seems to be what they're doing here: checking "has this program existed in this exact same state before?", because if it has, you're in an infinite loop. I seriously doubt it's as effective in the real world as they claim though: in my experience infinite loops simply don't happen in computing anymore. If your computer locks up, it's probably because you're in deadlock, or waiting on the disk or the network.

      --
      Dislike the Electoral College? Lobby your state to join the National Popular Vote Interstate Compact.
    3. Re:Halting Problem by Sduic · · Score: 1

      Actual computers are not Turing machines: because they have finite memory...

      Could encountering OOM errors, combined with some (perhaps non-deterministic) memory reclamation lead to problems with enumerating all of the states?

      --
      *this space intentionally left blank
      "One of the four pointers saying 'come and see', and I saw, and beheld a white
    4. Re:Halting Problem by Anonymous Coward · · Score: 0

      And this...is why people with just a bit of knowledge are dangerous. I'm no expert on turing machines ... but...these replies...are...dangerous. They're dangerous because they almost sound smart. MEMORY has NOTHING to do with the problem.

      It isn't that a computer has finite. The problem is one of recognition vs. classification. It is nearly *trivial* to recognize a program that halts. It is not trivial to recognize a program that does not. You can usually at best say "after 9.9e12 iterations, the program has not repeated itself"

      To find a program that halts--write a program that runs it, and run the program. If it stops--great, it halts. If it does not stop, run it a while longer. For all programs that stop, your program will eventually stop.

      The halting problem is about writing a program that can "meta-execute" this program without actually emulating it. This has nothing at all to do with memory, save the fact that recording and simulating the state takes...more than the original program would.

      They have solved a single, simple instance of LHALT, s.t. they keep a stack or list of previous program states, and check to see if they returned to a state they've already entered in. In turing mechanics you just need a set of parallel tapes, one which holds a stack with the state of the machine to scan against.

      This process won't detect a simple program that iterates over x+=1... but...it doesn't need to. It just profiles, and while you're in the same spot for too long...offers to take you to the other side of a branch. You might not actually be stuck there... maybe you're in a profiler routine that is timing how many times it can factor an integer in ten seconds...

      This... is one of the joys of runtime analytics...

       

    5. Re:Halting Problem by serviscope_minor · · Score: 2

      Here, the Halting Problem doesn't really apply, because if all else fails, you can (in theory) take every combination of programs up to N bits in length, and every combination of inputs up to M bits in length, and make a table of size 2^(N + M) saying whether a given program halts on a given input by running it and looking for a duplicate state.

      Provided you had an infinite amount of computer time.

      Tell me, does the following program halt:

      very long int h = 1;
      while(h)
          h = hash(h);

      does it halt of hash == md5? sha1? whirlpool? some PRNG?

      What if very long int is 2^32 bits long?

      Will the program terminate?

      Even in theory you can't solve the halting problem on a finite amount of computer time since you can construct programs where the hash function takes an arbitrary (2^(size of memory)) amount of time to loop, and it may not cycle through zero.

      Also, as well as infinite time, you need infinity squared memory.

      --
      SJW n. One who posts facts.
    6. Re:Halting Problem by Derekloffin · · Score: 1

      This doesn't solve the general case halting problem, only a specific subset of it. I could see this being useful in debugging phase of development, but not really for end users.

    7. Re:Halting Problem by Anonymous Coward · · Score: 0

      With finite memory, a program has finitely many possible states. Call the number of possible states N. Then a watchdog simply has to wait until either (a) the program halts, (b) the program runs for more than N steps. The former program halts, the latter does not, and no program that hits at least N+1 states can halt, because it must (at some point during its execution) have hit the same state twice.

      The whole "check to see if it's hit the current state before" is really just trying to speed up the process, since N will usually be prohibitively large. A program that allocates even one kilobyte of memory would probably run well past the end of the universe before hitting N steps, and all that jazz.

    8. Re:Halting Problem by AdmiralXyz · · Score: 1

      Even in theory you can't solve the halting problem on a finite amount of computer time since you can construct programs where the hash function takes an arbitrary (2^(size of memory)) amount of time to loop, and it may not cycle through zero.

      Sorry, but this is not correct. In the example you provided, you can determine whether the program will halt or run forever because h, however long it may be, can only take a finite number of values, and so the act of hashing h over and over is guaranteed to be periodic. Just keep running the program, keeping track of which values of h have been generated, until h = 0 (output HALTS) or until you see an already seen value of h (output DOES NOT HALT).

      --
      Dislike the Electoral College? Lobby your state to join the National Popular Vote Interstate Compact.
    9. Re:Halting Problem by medlefsen · · Score: 1

      This doesn't seem right to me. For example, imagine I make a "Magic halt detector" turing machine that limits the amount of memory used by the input program to a finite amount.

      After each instruction is executed, I can look at the total state of the finite tape, the position of the tape head, and the current instruction, and store it in a set of all seen states. If that state has been seen before, then I know it's an infinite loop. If not, then I simply add it and the execute the next instruction.

      Given a finite program with a finite alphabet and a finite memory, there is a limit on the total number of unique states. Eventually, either the program will have to repeat a state, or halt.

    10. Re:Halting Problem by Anonymous Coward · · Score: 0

      For finite inputs, this particular problem can be solved with finite time and space. Specifically, I have a (very naieve) algorithm that is O(2^n) in time and space (n is the number of bits in very long int) . The algorithm is to have a bit array of length 2^n, initially zero. Check if h is in the list at the beginning of the loop, if it is, the program doesn't terminate. Otherwise, record h in the list, and continue (i.e., h

      Of course, if n is big, this program takes a long (but still finite) time.

    11. Re:Halting Problem by FrootLoops · · Score: 1

      No, so long as the watchdog program isn't what's encountering these errors. Say the watchdog program runs your program in a tiny memory space--8 bits, so that the number of states isn't mind-blowing. An OOM error would modify this 8-bit state, cause the program to halt, or be ignored, depending on how errors are handled. Memory reclamation at any point would change the 8-bit state (possibly not modifying it at all), but all that would do is delay the inevitable. For instance, if you're in an infinite loop, after 2^8 + 1 = 257 iterations, you must have repeated your state. Perhaps without memory reclamation you might have detected the infinite loop after 60 iterations instead of 257, but oh well.

    12. Re:Halting Problem by blair1q · · Score: 1

      It's why ctrl-C still works.

    13. Re:Halting Problem by Anonymous Coward · · Score: 1

      Even in theory you can't solve the halting problem on a finite amount of computer time since you can construct programs where the hash function takes an arbitrary (2^(size of memory)) amount of time to loop, and it may not cycle through zero.

      Also, as well as infinite time, you need infinity squared memory.

      Patently false. A physical machine has a finite amount of memory, registers, etc. Hence, the machine has only finitely many states. Let's say there are L states in total. If the program ever reaches the same state twice, then it's in an infinite loop and will not terminate. Therefore, every terminating program reaches each of the L possible states no more than once. Run your program for L+1 operations. Either it has already terminated (so it halts) or it has reached some state more than once (so it will never halt). Either way, you have your answer.

      Of course, the value L would be so mindbogglingly huge that nobody in his right mind would ever even consider trying this approach...but in theory, it will work.

    14. Re:Halting Problem by Anonymous Coward · · Score: 0

      That must be why my computer didn't come with an infinite tape. I guess I won't return it now.

    15. Re:Halting Problem by Anonymous Coward · · Score: 0

      Holy smokes, way to fail at the halting problem.

      Short of "does hello world terminate?" that must be the easiest wrong HP example I have ever seen. The answer to your question is quite easy: just run the program and store all steps in a table. You are guaranteed that in finite (2^n, so 2^(2^32) in your case) steps you will either have come across 0 or 1, respectively output TRUE or FALSE and terminate.

      The HP says that you can not build 1 algorithm that will take as its input another program and will in finite time determine whether or not it halts. It is not about being unable to predict termination of actual given programs. The proof for the HP starts with the assumption that you have such an algorithm (call it F accepting two arguments: the program and an argument to call it with) and then shows that you could do impossible things. Basically, given the program F, construct another program, G, like this: G(x) := if F(x, x) = "terminates" then { loop } else { terminate }. Now what does G(G) do? If it terminates, then it loops forever, but if it loops forever, then it terminates. This is a paradox. No matter how you would solve the HP, you would get a paradox. Ergo the HP can not be solved.

      The OP was right. You do not need an infinite amount of computer time. Just "a lot" will do.

      Hope that clears some things up.

    16. Re:Halting Problem by dido · · Score: 3, Insightful

      True, as Marvin Minsky had once said: "...any finite-state machine, if left completely to itself, will fall eventually into a perfectly periodic repetitive pattern. The duration of this repeating pattern cannot exceed the number of internal states of the machine..." Emphasis in original. BUT, don't let that statement deceive you, as the number of states available to even a computer with very modest memory is so large that even the word 'astronomical' doesn't do it justice. For instance, my first real computer, a humble Commodore 64, with only 64K of memory, can have a total of 2^524288 (65536 * 8) states, something of the order of 1e157826 (yes, 157,826 zeroes after your one!) states. To give some idea of just how big that number of states is, were you to try to cycle through all such states at the astounding rate of 1e17 states per second (a theoretical 100 petahertz machine capable of cracking 56-bit DES keys in less than one second), it would still take 1e157801 years to go through them all. The heat death of the universe will have taken place after less than a thousandth part of that time has elapsed. As such Minsky goes on to say: "...the magnitudes involved should lead one to suspect that theorems and arguments based chiefly on the mere finiteness [of] the state diagram may not carry a great deal of significance." (Marvin Minsky quotes come from Computation, Finite and Infinite Machines, 1967).

      --
      Qu'on me donne six lignes écrites de la main du plus honnête homme, j'y trouverai de quoi le faire pendre.
    17. Re:Halting Problem by benhattman · · Score: 2

      No, it's still the halting problem. The GP was correct. They can't actually know if the program is in an infinite loop (halting problem) so they guess. Then, because they might be wrong they ask the user if they want to take an action to stop what "may" be an infinite loop. They've offloaded the real decision to a human and used a simple heuristic to help inform the human.

    18. Re:Halting Problem by Anonymous Coward · · Score: 0

      given that any hash function or PRNG will have to loop in finite time as their input an output is only finite. so you can just save the value of h in every iteration and test if you have seen it before. this of course works with finite memory as there are only finite iterations.
      arbitrary big numbers are still finite.

    19. Re:Halting Problem by Your.Master · · Score: 1

      You have two problems:

      One, you assume that the program operates only on memory. But it can have external input, which is an effectively infinite space. Polling the network card is an obvious case.

      Two, you assume that you can define and measure a number of "steps", which are wholly unique. You could argue that any cause for this is just a special case of the other problem, but it's a real problem for real programs. And this all started by debating that "real computers" don't meet Turing criteria.

      Counterexample, in pseudocode, using the internal timer:

      int main()
      {
              for(;;)
              {
                      if (GetSecondsElapsedSinceBootAsEightBitUnsigned() != 100)
                      {
                              if (GetSecondsElapsedSinceBootAsEightBitUnsigned() != 100) break;
                      }
              }
              return 0;
      }

      This is a program that may or may not terminate every 256 seconds, starting at 100 seconds in. It will terminate if and only if the timer "tick" occurs between the two if statements.

      You may say that part of the N states the machine might be in includes every possible timing for the second "tick" to occur in relation to the code execution, or perhaps every possible subdivision of the time between "tick"s down to the planck time. In which case I'd argue you're stretching the definition of "state", but even so the point remains that it's possible to repeat the exact same state multiple times before hitting the end state, unless you make the unrealistic assumption that CPU execution time is pristinely perfect with no variance whatsoever for all time. So executing N+1 times has no guarantee of terminating this function.

    20. Re:Halting Problem by Your.Master · · Score: 1

      Crap, sorry, the first if was supposed to be == and the second if !=. I think that should be clear from context.

    21. Re:Halting Problem by tokul · · Score: 1

      Tell me, does the following program halt:

      very long int h = 1;
      while(h)
      h = hash(h);

      It does not matter. Your code has potential infinite loop without any safety checks. It should be fixed or it should not be written than way in the first place.

    22. Re:Halting Problem by Anonymous Coward · · Score: 0

      That program will either halt or it will enter a duplicate state (when you are h overflows and then reaches 1 again) in finite time. Assuming hash always returns field we result for the same argument.

      That the finite time might be longer than the age of the universe is irrelevant, it is still finite.

      And yes it is completely impractical for an arbitrary program since your finite state space is the ram plus the disk plus the ram and disk of every reachable machine on the network plus that of the machines the can also reach and so on plus the space of all the machines providing input (say over radio broadcasts). But extremely large is still finite. Sure bigger than the number of quarks in the observable universe, but still finite.

    23. Re:Halting Problem by Anonymous Coward · · Score: 0

      Wowsers the "Let me change what you type to what I think you mean" on my phone went to town on that one...

    24. Re:Halting Problem by Anonymous Coward · · Score: 0

      with my infinite computer time, i run your code for a finite number of hashing algorithms.
      if one instance hasn't terminated after a specific fraction of my infinite computer time, it won't.

      if very long int is 2^32 bits long, you got a 512 MB datatype. congratulations!

      as for memory requirements: i need ca. 2*sizeof(very long int) ram. but wait: with my infinite computer time, i can swap to a punchcard of continuous paper and-
      no.
      since i have not infinite computer time, i better do something relevant now.

    25. Re:Halting Problem by Anonymous Coward · · Score: 0

      You can detect infinite loops, and you can even detect infinite loops without false positives. What you cannot do is detect infinite loops in *every possible program*. It is not the halting problem.

  11. Browsers by Anonymous Coward · · Score: 0

    Pretty sure most browsers do this now. (even IE, even Flash actually)
    When loop has been running too long, it halts and asks if the user wants to continue running it.

    I'm guessing it is a whole different ball-game when it comes to interpreted versus compiled?

    1. Re:Browsers by Short+Circuit · · Score: 1

      Different solution. This isn't a watchdog, this is a, "hey, this program's been here before. And once it's been here, it'll go there. And then there. And then here. And it won't stop."

      One bright side: The song that never ends...will.

    2. Re:Browsers by jellomizer · · Score: 1

      I have seen this case. It is not for infinite loops but just too long to process. I have seen it before in my preoptimized code. Usually when I give java script too much data.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    3. Re:Browsers by larry+bagina · · Score: 1

      Not the same thing...

      The browser sets a timer and calls the javascript interpreter. When the call returns, it clears the timer. If the timer goes off before the call returns, it asks if you want to stop javascript. Maybe javascript was in an infinite loop. Maybe it was performing a complex task and was just about to quit on it's own accord. The timer doesn't differentiate.

      This approach is a deeper probe (like being fisted by popeye vs your girlfriend sticker her finger in your asshole) -- it monitors the program state to find infinite loops.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

  12. Last by Anonymous Coward · · Score: 1

    Last

  13. Another advanced techiique to escape invinite loop by Shompol · · Score: 1

    Put a counter in all your loops. If the counter hits some arbitrarily ridiculous number throw an exception.

    This goes contrary to my management's belief that if anything goes wrong the program should "crash and burn".

  14. Some loops are less infinite than others... by Sduic · · Score: 1

    You are in a maze of twisty little branches. All alike.

    >_

    --
    *this space intentionally left blank
    "One of the four pointers saying 'come and see', and I saw, and beheld a white
  15. Now if only... by HighOrbit · · Score: 1

    Now if only they could get the software development unstuck from an infinite loop of project management, powerpoint slides, and TPS reports.

    1. Re:Now if only... by Anonymous Coward · · Score: 0

      Now if only they could get the software development unstuck from an infinite loop of project management, powerpoint slides, and TPS reports.

      Please make sure to use the new cover sheet on your TPS reports.

  16. Yea, but what happens.... by mat+catastrophe · · Score: 1

    ...if it goes into an infinite loop while trying to rescue another piece of code?

    --
    sig not found
    1. Re:Yea, but what happens.... by xMrFishx · · Score: 1

      The computer implodes and there's a fire.

    2. Re:Yea, but what happens.... by Anonymous Coward · · Score: 0

      Then, the next thing you know, there's money missing off the dresser and your daughter's knocked up, I seen it a hundred times.

  17. Re:Another advanced techiique to escape invinite l by Anonymous Coward · · Score: 2, Informative

    Listen to your management. Generally: failing silently is worse than failing noisily (is worse than not failing at all of course).

    In any case, your technique—unless you do a lot more analysis of your software than your comment suggests—will lead to a) lots of watchdog code cluttering up the logic and b) the software failing when it’s run on more data than you expected.

  18. This is done routinely by Anonymous Coward · · Score: 0

    This is done routinely on the Parallax Propeller multicore microcontroller. In general, CPU cores can easily watchdog each other.

    1. Re:This is done routinely by sjames · · Score: 1

      Watchdog timers are common. I've seen the timer fire on my DirecTV receiver a few times. However, those strobe reset rather than trying to surgically exit a loop.

      I would argue they are much more correct since reset is a well defined state.

  19. Near-ideal solution? by Twinbee · · Score: 1

    One thing I noticed in the article was this:

    and because of some fundamental results in computer science, “I know for a fact that he’ll never be able to get it exactly right.” But, Weimer says, “The vast majority of infinite loops he will be able to figure out.”

    Does this we can't get above a certain percentage of correct predictions, or does it mean that more and more work will converge towards 100% (99.5, 99.9%, 99.999% etc. etc.)

    --
    Why OpalCalc is the best Windows calc
    1. Re:Near-ideal solution? by Haedrian · · Score: 1

      No it means that no Computer Program can work out whether a program is in an infinite loop or not (Halting Problem), so he'll have to use heuristics to work it out. You can't get a 100% , because if you did you would have violated something which is mathematically proven.

    2. Re:Near-ideal solution? by Short+Circuit · · Score: 1

      Does this we can't get above a certain percentage of correct predictions, or does it mean that more and more work will converge towards 100% (99.5, 99.9%, 99.999% etc. etc.)

      It means one of those two things is true, yes.

    3. Re:Near-ideal solution? by Twinbee · · Score: 1

      Yes, but my question was not if you could reach 100%, but whether you could *arbitrarily close* to 100% given enough effort.

      --
      Why OpalCalc is the best Windows calc
    4. Re:Near-ideal solution? by Haedrian · · Score: 1

      Since we're talking about heuristics, given enough programs you could train it/program to be pretty close. But then you'd end up with a ton of false positives so its not very worth it. Plus the idea of force-exiting an infinite loop is a bad either anyway, so I'm not sure its worth it in any case.

    5. Re:Near-ideal solution? by dgatwood · · Score: 1

      Does this we can't get above a certain percentage of correct predictions, or does it mean that more and more work will converge towards 100% (99.5, 99.9%, 99.999% etc. etc.)

      Depending on what you mean by "work", either the latter or none of the above. The ability to detect a repeated state in a finite state machine is dependent on two things:

      • Number of states your storage can hold. The more complex the app, the more states you have. The bigger the set of possible states, the more states you can go through before you repeat a state. At some point, it starts to become rather prohibitive just to search through all the previous states.
      • Inclusiveness of each state. The more complex the app, the larger each state must be. For example, an app that zigzags back and forth through a file on disk, reading and writing, is going to be an absolute bear because ostensibly the entire file has to be considered part of each state. In practice, this can be simplified to a periodic snapshot plus a delta. Even so, this can become rather large.

      I you want a really brutal example of why it's hard, consider a program that reads the last four bytes of a file, then writes them beginning two bytes from the EOF marker, appending two bytes to the end of the file every time. Technically, you never repeat a state, assuming you consider the file position to be part of your state. However, you can still be repeating every other aspect of the state while only one part is changing, and one might consider that to be an infinite loop if there is not a loop test anywhere that checks that part.

      In practice, at some point, you run out of disk space, which means that any such app will eventually terminate. The question becomes one of whether you want to catch this otherwise infinite loop prior to that point, however. If you do, then you need to also detect patterns in the states (e.g. every value is now equal to every value plus k), and eventually, patterns in the patterns in the states.

      So it is possible to converge towards 100% acuracy, but the total size of the state history becomes so prohibitively large in practice that it doesn't generally make sense to go much beyond a certain level of accuracy. At some point, it makes more sense to pop up a slow script dialog or whatever and ask the user to decide whether the process is really hung or not.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    6. Re:Near-ideal solution? by Anonymous Coward · · Score: 0

      People don't know.

  20. Norton CrashGuard by Anonymous Coward · · Score: 0

    Sounds like Norton CrashGuard, a Symantec product that came out in the mid-90's bundled with Norton Navigator and, if I recall correctly, PC Handyman.

    Disclosure: I worked for Symantec at the time and made a major contribution to CrashGuard - the background graphic.

  21. Re:Interesting.... what about finite state machine by Anonymous Coward · · Score: 0

    Presumably, one would not use it on a finite state machine.

  22. They should this method by UnknowingFool · · Score: 1

    Escaping the RDF.

    Thanks, I'll be here all week. Tip your waitstaff.

    --
    Well, there's spam egg sausage and spam, that's not got much spam in it.
    1. Re:They should this method by Anonymous Coward · · Score: 0

      You should your method "the verb."

  23. uh-oh by drolli · · Score: 1

    All these endless loops which i created just to let some background threads executing....

  24. Misleading title by Illusion2269 · · Score: 1

    I thought this would be about how to get away from Apple headquarters.

    Boy do I feel silly....

  25. More like "Escaping non-Infinite Loops" by Anonymous Coward · · Score: 1

    If you can escape the loop, it's by definition NOT an infinite loop, right?

    1. Re:More like "Escaping non-Infinite Loops" by kwiqsilver · · Score: 3, Insightful

      So...if the computer eventually gives in to entropy, it's not an infinite loop?

  26. Re:Another advanced techiique to escape invinite l by Anonymous Coward · · Score: 0

    I'm not sure if you're going for a funny, or if you are a terrible programmer.

  27. Take one of what? by wjousts · · Score: 1

    when a duplicate state is detected it permits the user to take one a few actions to escape the loop.

  28. article is a dup by Anonymous Coward · · Score: 1

    This story was posted here last week, with many of same snarky observations.

    1. Re:article is a dup by freedumb2000 · · Score: 1

      nice

  29. Anyone remember Norton Crash-guard/anti-freeze by slew · · Score: 2

    I seem to remember the old norton crash-guard/anti-freeze utility that was somewhat useful in getting around problems like infinite loops in old Windows programs.

    I'm pretty sure the way this worked takes advantage of the fact that windows programs are essentially structured as message-processing co-routines plugged into a infinite scheduling loop (the windows loop). Although mostly, messages are posted, sometimes these messages can go re-entrant and if poorly coded cause an infinite loop. Anti-freeze could be then "sprayed" on the app which would then try to insert or delete messages in the program's processing loop to help it exit the re-entrant part loop and go back to the main scheduling loop. Often this would work well enough to enter the "Save" menu processing part of the program to avoid losing work. It also attempted to handle traps effectively (things that often happen when a program runs past the end of an array if it's in an infinite loop) by suspending the main flow of the program and inserting another message and thread to try an allow for limited operation (like "Save" menu processing).

    Unfortunatly, this technology wouldn't be that effective in todays environment (basically, it probably could be classified as malware/spyware so the defenses against malware/spyware woud probably prevent it from working), but it seems like bulding this into an application code development infrastructure seems like it might be a good idea...

    1. Re:Anyone remember Norton Crash-guard/anti-freeze by ZiggyM · · Score: 2

      yes I had that [norton?] antifreeze program too over 15 years ago. It gave you the option to jump out of an infinite loop (at your own risk) and most of the time that was good enough to unfreeze the entire (16 bit) computer, save your files.

  30. Just another debugger? by mj1856 · · Score: 1

    From TFA: Jolt works in conjunction with a compiler, a program that translates code written in a high-level programming language into rudimentary instructions that a computer can understand. When an application is being compiled, Jolt marks the beginnings and ends of all the loops indicated in the source code. If the compiled application later stalls, Jolt simply forces it to skip ahead to the first instruction following the loop it’s stuck in.

    Wouldn't this be like using a symbol file? In .Net, for example, a .pdb gets generated when you compile in debug mode. You can certainly then attach a debugger to a program stuck in an infinite loop and tell the debugger to jump to the code following the loop. It sounds like they're just doing this in some automated way.

    Of course this completely ignores any benefit of compiler optimization when compiled without symbols in "release" mode. Not to mention making it impractical to obfuscate your code to prevent disassembly. Seems like a really bad idea overall.

    1. Re:Just another debugger? by Anonymous Coward · · Score: 0

      Not to mention making it impractical to obfuscate your code to prevent disassembly.

      A good thing.

  31. I've done that by hand by greed · · Score: 1

    Back in my days as a software tester, that's basically what I would do when I suspected something was looping. Wedge a debugger into the running process, see how far the program counter was going, and see what registers were changing, and a quick look at the autos in the current stack frame. (Most autos would be in registers: this was not an x86-based system.)

    I made no attempt to get the program to continue, though; once I was pretty sure it was in a loop, I'd then work out the minimum necessary circumstances to trigger it and log a bug report.

  32. One Infinite Loop, Cupertino CA by billstewart · · Score: 1
    • Insert Apple Fanboi Response Here!
    • Our hardware is so fast it can do infinite loops in 2.6 microseconds!
    • Infinite Loop was better when it had the Computer Literacy Bookstore branch, and the Peppermill down the block!
    • Insert your own insanely great response here!
    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
    1. Re:One Infinite Loop, Cupertino CA by Anonymous Coward · · Score: 0

      I work inside one Infinite Loop you insensitive clod!

  33. Bypass the interface by arbulus · · Score: 0

    Bypass the interface

  34. backtracking? by Anonymous Coward · · Score: 0

    I imagine the software does the best it can to look at everything involved in arriving at the loop and tries to take the user to the nearest user-interruptable point just before the loop occured. If the program could also keep track of registers and variables for some number of changes or period of time, then it could even restore any relevant variables to what they were at the exact moment it decides to take you back to, and with all that work why not also make it spit out debugging for the state it had to break out of? Does this thing do all that? Who wants to write something like that?

  35. If it's good enough you can just roll it in by Anonymous Coward · · Score: 0

    Wow, cool idea! If it's good enough you can just roll it into the program and it'll work like you want (end sarcasm).

  36. Possibly useful for AI by Anonymous Coward · · Score: 0

    This sounds like a terrible ID for programs written by people for a specific goal. It could be useful for artificial intelligence. We could presume that a learning algorithm would make the infinite loop mistake sometimes.. Being able to break from the loop and try something else would be useful.

  37. But WAIT, it is incomplete... by Anonymous Coward · · Score: 1

    This solution serves NO purpose unless it is also accompanied by a modal dialog with this text:

    Infinite loop detected! Do you want to break the infinite loop?

    With one button labelled "OK".

  38. Remember not to use Jolt on your drivers by Anonymous Coward · · Score: 0

    Seems your keyboard handler was stuck in an infinite loop, so I jumped out of the loop for you. You can thank me later...

  39. It's east, look at the post below mine by Anonymous Coward · · Score: 0

    It's east, look at the post below mine

  40. Unrealistic use case, limited scope by vivaoporto · · Score: 1
    From TF Paper

    Subject: Thanks

    I was writing a document in Word this morning, and after about an hour of unsaved work, Word went into an infinite loop that made the application completely frozen. So, having listened to your talks too many times, I got my debugger, paused the program, changed the program counter to a point a few instructions past the end of the loop, and let it keep running from there. Word went back to working as if nothing had ever happened. I was able to finish my document, save it, and close Word without problems.
    So thanks,
    Armando.

    If that's a real use case scenario, thing must be really different in MIT than they are in the real world. Users, even with a technical background don't have a clue about what an infinite loops looks like, let alone open a debug and move out of it.

    If that's the target audience, not having the overhead of the automatic detection for the other 99% and letting the tech savy fend for themselves with the debugger. Also, the scope is too limited.

    As the application executes, Jolt compares the current state with the state from the previous iteration. If the states are equal, Jolt has detected an innite loop.

    As the paper itself says, it doesn't "detect loops due to recursion or unstructured control ". It could probably be fooled by some busy waiting loop.

    Doesn't seem like a serious paper, or something that solves a serious problem.

    1. Re:Unrealistic use case, limited scope by Anonymous Coward · · Score: 0

      Agree. Also, who doesn't hit Ctrl+S at the end of each thought when using Word or any other editing program? Also, this is exactly what Word's document recovery is designed for. It always works. It is saving a transaction log of the document (relative to the last save) with every letter added, erased etc. This is what those hidden ~blahblah files that get created temporarily next to your document are.

      Incredible this person at MIT doesn't know of these two simple things (saving every time you take a break from typing is computer use 101). He could have killed the program and recovered his document. He over engineered when MS already thought of this case. I can't think of many other times where this would be useful.

      I imagine hitting the save button after jumping out of a loop that's hung the program may cause more harm than good. I can think of a few line of business apps that appear to lockup when writing to the database. Would be great to fuck up the database because you jumped out of a very lengthy loop.

      It would have been funny if he hosed his document and the recovery file with this stunt. Double bonus for not saving for an hour. Really, he thinks he sounds clever and smart but he sounds like a dumbass that will waste time and over-engineer everything. Also, would not hire him because he clearly doesn't identify risk well not saving more often.

  41. Infinite loops by dominious · · Score: 1

    I'm running on a micro-controller you insensitive clods!

    1. Re:Infinite loops by angel'o'sphere · · Score: 1

      My mind state is running on a micro-controller, you insensitive clod!

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  42. PL/C and PL/I Checkout Compiler also "fixed" bugs by billstewart · · Score: 1

    The standard teaching language at Cornell in the mid-70s was PL/C, Cornell's version of the IBM PL/I Checkout Compiler. It didn't "fix" infinite loops, but if "fixed" a lot of simple syntax errors and some runtime errors like "divide by zero" or out-of-bounds array indexes.

    Sure, it wasn't always reliable, and could even cause infinite loops rather than preventing them, but it still let you speed up the code-keypunch-wait-run-debug cycle a lot. Fixing the syntax errors meant that you could usually identify all your syntax errors in one run (especially simple ones like forgetting a statement-delimiting semicolon or using the wrong number of closing parentheses), and could often find where you had logic errors even though it didn't always do the right thing (e.g. replacing an out-of-bounds array index with "1" was seldom correct, but it told you you'd done something wrong.) Since the development cycle typically included "wait for a keypunch", "wait to put your cards in the reader" and "wait for your batch job to come out of the printer", and the computer labs got overcrowded when CS100 projects were due, this was a big win.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  43. Illiac had infinite loop detection by uigrad_2000 · · Score: 5, Interesting

    Here at the U of I, we built the 4th computer ever made: the Illiac

    24 hours a day, an operator would sit at the computer to operate it. "Software" or jobs would be submitted by faculty. When one finished, the operator would load the next one.

    Since only one job could be running at a time, it was quite important to detect infinite loops. The last bit of the ALU was connected to a speaker, and would produce sound similar to static when the computer was running correctly. If an infinite loop was encountered, then the static would suddenly hum a pitch, and the operator would kick out the job, and move to the next.

    As the story goes, the very first machine music was written by a math professor, and submitted as an Illiac job, as a prank on the operator. Sometime around 3am, the operator picked up the next job and fed it to the machine. Immediately, the Illiac began playing "Hail to the Orange"!

    --
    Free unix account: freeshell.org
    1. Re:Illiac had infinite loop detection by Anonymous Coward · · Score: 0

      Man, thank you for sharing this awesome piece of computer history ;)

    2. Re:Illiac had infinite loop detection by Umuri · · Score: 0

      My kingdom for some mod points for this man. Thanks for the historic anecdote. I love tales from the old uni comps like this.

      --
      You never realize how much manually made unmanaged "linked" lists suck, till you have src.link.link.link.link...
    3. Re:Illiac had infinite loop detection by rubycodez · · Score: 1

      Fourth computer? Plenty of electronic computers were built in the 1940s before Illiac I, more than ten . Also, what happens if a program is doing algorithm where ALU is the same until some unique condition met? That's hardly a foolproof method of infinite loop detection

    4. Re:Illiac had infinite loop detection by Anonymous Coward · · Score: 0

      older winchester drives used to make the floor shake enough
      for you to tell the compile was normal.

      jr

    5. Re:Illiac had infinite loop detection by kevmeister · · Score: 1

      Probably would have gotten an even stronger response if it had played "On Wisconsin".

      --
      Kevin Oberman, Network Engineer, Retired
    6. Re:Illiac had infinite loop detection by FrootLoops · · Score: 1

      I listen for repeated hard drive noise when a machine seems to have hung. A lot of the time you can hear a "click...clickclickclick...click" repeating again and again (or something similar; usually a bit more complex) when it really has hung.

    7. Re:Illiac had infinite loop detection by Waccoon · · Score: 2

      It's really cool to hear an early example of listening to code. "RAM scanning" was popular on the Amiga many years ago, and it was pretty easy to guess what kind of data was present in the system's memory just by listening to it. Images, code, pre-calculated tables, and text all had unique sounds, so just pumping some memory into the speaker was way faster than looking at a bitmap screen offset or using a hex editor. I used to be able to rip Soundtracker music from games with only a sound editor and nothing else.

      I wish I could still do that on a PC. It'd be cool to see what a memory looks and sounds like with a modern OS, even though it'd probably be fragmented to hell.

    8. Re:Illiac had infinite loop detection by naturaverl · · Score: 1

      You're kidding, right?

    9. Re:Illiac had infinite loop detection by FrootLoops · · Score: 1

      No.

  44. NMI button by equex · · Score: 1

    The Amiga could be soldered to add a button that would trigger the Non Maskable Interrupt, pressing this would throw you back into AsmOne if you got stuck :)

    --
    Can I light a sig ?
    1. Re:NMI button by Frogking · · Score: 1

      I also remember a program called GOMF (Get Out'a My Face) that let an Amiga user abort a program after the dreaded Guru Meditation Error threatened to crash the entire system. Ah, good times!

  45. Just remember the number 3 by Pete+McCann · · Score: 1

    And listen to Riker this time around.

  46. Breaking my infinite loops would be easy... by kwiqsilver · · Score: 1

    Just make 1 false. However, I can foresee a few unwanted side effects...

    1. Re:Breaking my infinite loops would be easy... by rubycodez · · Score: 1

      You should love Unix exit codes then

  47. I'd rather crash by jader3rd · · Score: 1

    Moving the instruction pointer out of the loop could do more harm than good. It puts the code in an unverifiable state. I'd much rather get a crash dump with some sort of InfiniteLoopHereException.

  48. A Great Solution by camionbleu · · Score: 2

    The algorithm is:

    1: Enter infinite loop
    2. Invoke Jolt to escape from infinite loop.
    3: GOTO 1

  49. Re:Interesting.... what about finite state machine by dgatwood · · Score: 1

    The state of an app is a lot more than just the state of the variables within the app.

    For example, if you're reading from (and not writing to) a file, you have a file pointer that changes. If you get back to the same point in the FSM with a different file pointer value, it's not the exact same state. If the file pointer has the same value, it is. If you're writing to the file, it gets a lot more complicated rather quickly, but you get the basic idea.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  50. pauli exclusion principle by Anonymous Coward · · Score: 0

    There is no duplicate state

    A duplicate state is forbidden by quantum mechanics

  51. Old Comp Sci joke by Michael+Woodhams · · Score: 1

    Hey, have you heard about the new Cray 2 computer? It is so fast, it can finish an infinite loop in under 10 seconds!

    (That is how I heard it. They probably told the same joke about the IBM 360. Modern supercomputers aren't much faster at infinite loops, but they can do 20,000 at once.)

    --
    Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
  52. does it work with c++ templates? by decora · · Score: 1

    waiting for them to compile seems a lot like waiting for a lineprinter

    1. Re:does it work with c++ templates? by billstewart · · Score: 1

      The free batch-job handler that most student projects used gave you 1 second of CPU time and 6-10 pages of output (depending on the year.) But if things were busy, it might take an hour between the time you queue up to put your cards into the reader and the time your printout arrives. A few years later, I was taking a compiler course at night, and could either do my work on a VAX shared with about 30-40 other people, or on a mainframe running a somewhat odd version of Unix, which usually only had a couple of interactive users on it - it was really amazing to be able to type "cc myproject.c", hit carriage return, and get a $ prompt back immediately.

      --

      Bill Stewart
      New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  53. kip al bad by decora · · Score: 1

    bad start cookie

  54. Windows 7 Fault Tolerant Heap by TopSpin · · Score: 1

    This reminds me of the Windows 7 Fault Tolerant Heap. When the OS detects frequent crashes of a program it may 'shim' the memory management operations (malloc/free) to prevent future crashes. This can, for instance, prevent a crash when a program references recently free'd memory; the OS will deliberately leak that memory and the program keeps on spinning. Double frees can also be automatically mitigated. The heuristics involved will actually analyze the results of these efforts and back out the 'shims' if necessary.

    not intended for use in a nuclear installation

    --
    Lurking at the bottom of the gravity well, getting old
  55. There's a Chuck by n6kuy · · Score: 1

    ... Norris joke in here somewhere...

    --
    If you disagree with me on social issues, then it's pretty clear that you are a narrow-minded bigot.
  56. Evil input data by gmuslera · · Score: 1

    What if you don't have an infinite loop, but your random input data make you look like one?

  57. Nominal conditions. by blair1q · · Score: 1

    Any off-nominal condition I can detect and repair becomes a nominal condition. And I have well-tested code handling all nominal conditions. Thanks for the new design pattern, though. It'll come in handy.

  58. Not about career advice? by CityZen · · Score: 1

    From the subject line, I was sure this would be an article about career advice. Ah well, back to grind.

  59. If you can escape an infinite loop... by Memroid · · Score: 1

    ...is it really infinite?

  60. Yow! by sjames · · Score: 1

    I'm sure that'll go swimmingly! What's an indeterminate state between friends?

    There are three valid ways to "handle" an infinite loop. Most commonly, just keep looping until the user kills the program. In the embedded world, the most common is that a watchdog timer hard resets the device. In some cases, use alarm and let SIGALRM terminate the program (possibly after a bit of debug log is written).

    Otherwise, if the loop can be infinite due to external conditions, it should be handled by the programmer so things can be put in a determinate state.

    1. Re:Yow! by emt377 · · Score: 1

      In the embedded world, the most common is that a watchdog timer hard resets the device.

      This only works if the watchdog poke isn't inside the infinite loop.

      I actually think this is an excellent tool, not so much to notify users but as a debugging and test aid. Add it to valgrind/helgrind. Tell me when an iteration of a loop doesn't result in a change in state - this is clearly an anomaly and tells me it is dependent on an external condition to unwedge. Loops which are intended to wait for external events (like a spin lock or other atomic operation) I can flag as such to exempt from the instrumentation. This encourages factoring out such behavior into small more easily verified and debuggable/portable units - a good idea to begin with. I think the instrumentation sounds excellent - add it to valgrind!

    2. Re:Yow! by FrootLoops · · Score: 1

      I imagine this could be useful for debuggers. Of course I didn't RTFA.

    3. Re:Yow! by sjames · · Score: 1

      Detecting an infinite loop as a debugging tool is quite a different matter! I agree that that is a useful thing. Detecting the loop and resetting in a production embedded system is also good if the detection isn't too much load on the system and it doesn't have false positives.

      My objection is to the idea of just moving to the next line and assuming all is fine now.

  61. Bad idea by Anonymous Coward · · Score: 0

    I hate things that make badly written or poorly configured software "mostly" work. How about something that makes software fail unless it's written correctly in the first place?

  62. LBA vs. Turing by tepples · · Score: 2

    The undecidable nature of the halting problem

    ...is true only of Turing machines, which have unbounded memory. In some ways, a linear bounded automaton is a better model for realizable computation than a Turing machine, and the halting problem is decidable on these.

  63. Shampoo... by nilram · · Score: 1

    You mean ... I can finally stop washing my hair!

  64. Re:Another advanced techiique to escape invinite l by smellotron · · Score: 1

    Put a counter in all your loops. If the counter hits some arbitrarily ridiculous number throw an exception.

    Replace "throw an exception" with "kill myself with a core dump" and you have yourself a deal! I mean something like SIGABRT (a.k.a. abort()) or SIGQUIT. I can see value in preventing infinite loops, because faulty program exits tend reveal their errors more "naturally" than hung programs.

    But exceptions are baaaad in this case. Exceptions can be caught and ignored. An infinite loop like this is a logic error and the entire program state must be considered suspect/unreliable.

  65. Re:PL/C and PL/I Checkout Compiler also "fixed" bu by Anonymous Coward · · Score: 0

    Oh. Debugging code. I thought this was about escaping Apple.

    It just works on iOS

    (joke, funny, haha... lighten up)

  66. Linus on infinite loops by Anonymous Coward · · Score: 0

    We all know Linux is great it does infinite loops in 5 seconds. (unsourced alas)

  67. User interaction? by RichiH · · Score: 1

    Either this works for high-level stuff only or there is a _lot_ of magic added for the benefit of shoddy programmers getting away scot-free.

  68. bad things come from this by hesaigo999ca · · Score: 1

    People have bad habits forming, but if they rely on other means to circumvent their own stupidity, then it really is enforcing bad habits to the core....how about just being smarter with your logical thinking?

  69. A pointless exercise by Horus1664 · · Score: 1
    An interesting project for college students that have been programming for months but ultimately pointless. Just fix the program.

    Corollary: Don't use MS Word.

  70. Re:Another advanced techiique to escape invinite l by Shompol · · Score: 1

    This was not your typical university project or even a system written by programmers. I used this technique in a monstrous behemoth ported from mainframe, most "API's" had been written over the past 40 years by non-programmers.... in Fortran. The whole system is one huge point of failure waiting to happen. If you think this is funny, it probably is, but the circumstances warranted this technique, because infinite loops happened more often than your average customer is willing to tolerate.

  71. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion