bugGNU Octave - Bugs: bug #40319, deleting script file in a...

 
 

bug #40319: deleting script file in a function/script doesn't update the symbol table

Submitted by:  Pantxo Diribarne <pantxo>
Submitted on:  Sun 20 Oct 2013 09:29:09 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: Need InfoAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 14 Feb 2014 01:44:09 PM UTC, comment #7:

Sorry for the late reply. I agree with you that there are many ways to make a function file disappear and we should not try to manage all of them individually.

The reason why the example works in the terminal and not in a script, is that the path is updated before parsing each input from the prompt (in octave_base_reader::octave_gets from input.cc).

For exist and which functions it seems reasonable to update the path before anything is done.

As it is not reasonable to update the path after each line of a script/function, a test is run (out_of_date_check) from various symbol_table::fcn_info::fcn_info_rep::find_xx functions.

Unfortunatly, the test only checks that the last time the function file was checked is ulterior to last prompt and last dir change.

As a consequence, not only deleted files, but also modified are affected : let's say I have a script toto.m that modifies a second script toto2.m and then runs it. The old version of toto2.m will be run because according to the criteria in out_of_date_check, it is up to date and doesn't even have to be parsed again.

The test should also check that the last time the file was modified is anterior to both last prompt and last dir change. Not sure this may be done fast enough (with stat?).

Pantxo Diribarne <pantxo>
Thu 24 Oct 2013 03:40:54 AM UTC, comment #6:

Because delete may not always be used to delete script files? It seems a little hackish to me to reload the path in a function that may or may not add or remove a function that's in the symbol table. What about unlink("script.m")? What about system("rm -f script.m")? Or what if script is never called again after the delete, why bother reloading the path?

It seems better to try to reload the path and look up again on demand when a symbol is actually used and can't be found.

Mike Miller <mtmiller>
Project Member
Wed 23 Oct 2013 01:35:26 PM UTC, comment #5:

Why not rehash in delete.m if we have deleted a script file that were in the path. Then delete.m is responsible for letting the symbol table in an up to date state.

Pantxo Diribarne <pantxo>
Tue 22 Oct 2013 01:10:12 PM UTC, comment #4:

Here's how far I've dug into this:

The exist function ends up calling the static symbol_table::find function. Further down in the symbol_table class are a couple of calls to load_path::update(), which is what rehash does. It looks like there is some logic in place to attempt to reload the path if a find fails, but I haven't traced the symbol_table class enough yet to know under what conditions it's done.

Mike Miller <mtmiller>
Project Member
Tue 22 Oct 2013 07:26:31 AM UTC, comment #3:

I didn't know the rehash command. That's exactly what I think should be done right after deleting a file which is in the path.

I see no good reason why that script should work in the command line (if I copy/paste in octave prompt I obtain the good results immediatly, no need to rehash) and not from a function/script file.

Pantxo Diribarne <pantxo>
Tue 22 Oct 2013 01:24:39 AM UTC, comment #2:

I'm not sure, but perhaps this is expected behavior? For example, after the testdelete script returns, exist returns 2. Also if I add

to the end of testdelete, I first get retval = 0, then retval = 2. Is it perhaps expected that the load path is only automatically refreshed when Octave is interactive and it returns to the prompt?

Mike Miller <mtmiller>
Project Member
Sun 20 Oct 2013 09:32:32 PM UTC, comment #1:

Sorry, I forgot to mention that the first part was meant to be run from a script (attached).

(file #29432)

Pantxo Diribarne <pantxo>
Sun 20 Oct 2013 09:29:09 PM UTC, original submission:

If I delete a script file in a script or a function, I have to go back to prompt to have the symbol table updated. The following test shows the bug:

retval should be 2 and I see 0 instead. Back in the octave prompt, evaluating the last line gives the good result:

Pantxo Diribarne <pantxo>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #29432:  testdelete.m added by pantxo (305B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by pantxo (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 22 Oct 2013 01:24:39 AM UTCmtmillerCategoryNone=>Interpreter
      StatusNone=>Need Info
    Sun 20 Oct 2013 09:32:32 PM UTCpantxoAttached File-=>Added testdelete.m, #29432

    Back to the top


    Powered by Savane 3.1-cleanup