bugGNU Octave - Bugs: bug #61926, Coding infinite loops in Octave


bug #61926: Coding infinite loops in Octave

Submitted by:  None
Submitted on:  Wed 26 Jan 2022 06:50:05 AM UTC
Category:  None Severity:  2 - Minor
Priority:  3 - Low Item Group:  None
Status:  Invalid Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.1.0
Operating System:  * Microsoft Windows
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Sat 09 Apr 2022 01:14:32 PM UTC, comment #3: 

No response in 3 months.  Closing as invalid.  Re-open if there is more information to provide and a real issue here that needs to be fixed.

John W. Eaton <jwe>
Project Administrator
Wed 26 Jan 2022 04:54:37 PM UTC, comment #2: 

I agree that this is a strange way to loop, but it should work as a way to execute a script in a completely fresh Octave session each time.  It works for me on a Debian system.

The OP tagged this as a problem with Windows.  Is fun.m in Octave's loadpath?  Is it possible that the Octave's startup directory has been set to some location other than where fun.m is located and that fun.m is not found?

However, in the original, the system command waits for the child to exit before it returns.  So you'll end up accumulating Octave processes until you run out of memory or the ability to execute a new process.  The following works for me to avoid that problem.  I added the call to "pause" so that I'd have a chance to kill the current process and terminate the loop.

## infloop.m

system ("echo 'pause (5); infloop; exit' | octave", false, "async");

BTW, the savannah bug tracker doesn't use ``` to indicate verbatim markup.  See the notes about markup tags here: https://savannah.gnu.org/bugs/?group=octave&func=additem

John W. Eaton <jwe>
Project Administrator
Wed 26 Jan 2022 04:01:31 PM UTC, comment #1: 

What is the use case for this particular construction?

If you need an infinite loop just use looping structures while, for, or do/until with infinite bounds.


while (1)

for i = 1 : Inf

until (0)

Rik <rik5>
Project Administrator
Wed 26 Jan 2022 06:50:05 AM UTC, original submission:  

File fun.m:
system ("echo 'fun ; exit' | octave")

Expected infinite loop but stops in 2 iterations.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.





    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-09 jwe StatusNeed Info => Invalid
        Open/ClosedOpen => Closed
    2022-03-07 rik5 Severity3 - Normal => 2 - Minor
        Priority5 - Normal => 3 - Low
    2022-01-26 rik5 StatusNone => Need Info
        Summaryinfinite loop ends too quickly => Coding infinite loops in Octave

    Back to the top

    Powered by Savane 3.9