bugGNU Octave - Bugs: bug #42882, Discrepancy between eval()/run()...

 
 

bug #42882: Discrepancy between eval()/run() and source() when calling external .m file

Submitter:  None
Submitted:  Thu 31 Jul 2014 02:17:01 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Duplicate Assigned to:  None
Originator Name:  Jonathan Dodd Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 31 Jul 2014 01:20:10 PM UTC, comment #3: 

Closing as a duplicate of bug #42883 as suggested in comment #1.

Mike Miller <mtmiller>
Group Member
Thu 31 Jul 2014 02:36:13 AM UTC, comment #2: 

Resubmitted here.

Jonathan Dodd <gnathan87>
Thu 31 Jul 2014 02:24:59 AM UTC, comment #1: 

Oops, very sorry - ignore this report, I forgot to edit the title  once I had finished composing the main bit. I will resubmit with a better title.

Jonathan Dodd <gnathan87>
Thu 31 Jul 2014 02:17:01 AM UTC, original submission:  

This report relates to the lack of re-compilation of a .m file when it changes during the execution of a script. This may be intentional/desirable for performance reasons. However, it seems to differ from Matlab, causes a discrepancy between normal execution and execution in debug mode, and should be made explicit in the documentation.

The context in which I came across this behaviour related to an existing non-Octave program adapted to output matrices in .m format. A loop in my Octave script ran this program with different input parameters before calling the resulting .m file to load the data. I had expected each new data set to be read from the output file in turn, but in fact only the first data set was ever used.

Curiously, each new data set was correctly loaded in debug mode. This may be because Octave checks for changes at each new line when running interactively, as explained here. Thus, a changing .m file is not re-compiled when a script is running normally, but is re-compiled when step-debugging - clearly undesirable.

While the documentation does cover the re-compilation of changing files, it is not immediately obvious that files will not be recompiled during the execution of a script - even with ignore_function_time_stamp("none"). I therefore suggest that this is made explicit, and it is explained that if .m files change during script execution, the relevant function should should either be cleared, or the script file run using source() or run(), which ensure re-compilation.

Finally, in contrast to Octave, Matlab does seem to re-compile functions during script execution, but only after a time delay of about 1 second. However, experiments seemed to indicate that this behavior was in fact quite undesirable, producing different outputs depending on the time at which the script was executed (NB this was relayed to me on IRC - I am unsure whether it related to straight calls, calls through run() or both).

Example


See attachment. Comment out lines in foo() as appropriate. using run() or source() will result in y=1, 2, ... , 10. Calling testb directly results in y = 1, 1, ... , 1. Matlab may produce something like y = 1, 1, 1, 1, 6, 6, 6, 6, 6, 6, depending on the run.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31803:  recompiletest.m added by None (274B - text/x-objcsrc)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by gnathan87 (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 group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-07-31 mtmiller StatusNone Duplicate
        Open/ClosedOpen Closed
        Dependencies- Depends on bugs #42883
    2014-07-31 None Attached File- Added recompiletest.m, #31803

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code