bugGNU Octave - Bugs: bug #59439, function handles should be able to...

 
 

bug #59439: function handles should be able to reload subfunctions

Submitted by:  Dmitri A. Sergatskov <dasergatskov>
Submitted on:  Tue 10 Nov 2020 01:56:58 PM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Wed 11 Nov 2020 09:32:58 AM UTC, comment #6: 

I pushed a change that locks "legend.m" here:
https://hg.savannah.gnu.org/hgweb/octave/rev/9aec2c6ad40c

Changing release to "dev" for a proper fix.

Markus Mützel <mmuetzel>
Project Member
Tue 10 Nov 2020 09:09:27 PM UTC, comment #5: 

Thanks for the info.

I think the quick fix of adding mlock to the legend function may be the best thing for the version 6 release.  Maybe we can fix this issue properly for version 7.

John W. Eaton <jwe>
Project Administrator
Tue 10 Nov 2020 05:01:28 PM UTC, comment #4: 

With Matlab R2020b:

>> clear all
>> fh = foo ();
>> fh ();
initializing foosuba:val
foosuba
initializing foosubb:val
foosubb
>> fh ();
initializing foosuba:val
foosuba
initializing foosubb:val
foosubb
uncomment this line
>> clear functions
>> fh ();
initializing foosuba:val
foosuba
initializing foosubb:val
foosubb
uncomment this line

Markus Mützel <mmuetzel>
Project Member
Tue 10 Nov 2020 03:52:07 PM UTC, comment #3: 

Can someone run the following tests using the foo.m file I'm attaching?  Execute the following commands manually at the Matlab prompt and report the output.

fh = foo ();

%% Calling the function handle should display messages
%% about initializing persistent variables.

fh ();

%% At this point, edit foo.m and uncomment the call to
%% fprintf in the foosubb subfunction.

%% If the functions referenced by the handle fh are
%% reloaded when calling foo:foosuba through the handle,
%% then we should see the messages about initializing
%% the persistent variables again.

fh ();

%% Now clear the functions from the interpreter.

clear functions

%% If the functions referenced by the handle fh are
%% reloaded when calling foo:foosuba through the handle,
%% then we should see the messages about initializing
%% the persistent variables again.

fh ();

(file #50238)

John W. Eaton <jwe>
Project Administrator
Tue 10 Nov 2020 03:00:57 PM UTC, comment #2: 

For compatibility with Matlab, the subfunction should probably be able to reload.

The attached example has the following output in Matlab R2020b if I click the button twice before and after `clear all`:

>> clear all
>> bug59439_function
test: 1
test: 2
>> clear all
test: 1
test: 2

The same in Octave 6.0.92:

>> bug59439_function
>> test: 1
test: 2
clear all
>> error: 'subfunction' undefined near line 6, column 6
error: called from
    bug59439_function>@<anonymous> at line 6 column 79

Very similar error in 5.2.0. So this isn't a regression.

I don't think the general issue should block the Octave 6 release. Maybe a short time fix could be made to "legend" though.

(file #50237)

Markus Mützel <mmuetzel>
Project Member
Tue 10 Nov 2020 02:16:17 PM UTC, comment #1: 

reset_cb is a subfunction in legend.m and clear all is deleting the legend function.  I'm not sure whether the function handles that are created inside that function are supposed to be able to reload the legend.m file if it has been cleared?  Adding a call to mlock at the top of the legend function will avoid this problem, but that is probably not the correct or long-term fix.

John W. Eaton <jwe>
Project Administrator
Tue 10 Nov 2020 01:56:58 PM UTC, original submission:  

Sorry for vague summary, but i am not even sure if the problem
with legend or with octave interpreter in general.

octave -q -f
octave:1> plot(1:10, "-;test1;")
octave:2> clear all
octave:3> close all
error: 'reset_cb' undefined near line 481, column 481
error: called from
    legend>delete_legend_cb at line 481 column 3
    delete at line 65 column 5
    closereq at line 44 column 5
    close at line 119 column 5
error: delete: first argument must be a filename or graphics handle
error: called from
    delete at line 68 column 5
    create_item>@<anonymous> at line 1060 column 30
    delete at line 65 column 5
    closereq at line 44 column 5
    close at line 119 column 5
octave:4> __octave_config_info__ ("hg_id")
ans = b71672c8d337

(this is actually octave 6.0.93)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50238:  foo.m added by jwe (398B - text/x-objcsrc)
file #50237:  bug59439_function.m added by mmuetzel (300B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-11-11 mmuetzel StatusNone => Confirmed
        Release6.0.92 => dev
        Operating SystemGNU/Linux => Any
    2020-11-10 jwe Attached File- => Added foo.m, #50238
    2020-11-10 mmuetzel Attached File- => Added bug59439_function.m, #50237
        CategoryPlotting => Interpreter
        Summarylegend issue => function handles should be able to reload subfunctions

    Back to the top


    Powered by Savane 3.5