bugGNU Octave - Bugs: bug #47828, persistent handle to function with...

 
 

bug #47828: persistent handle to function with subfunction fails after "clear all"

Submitter:  Julien Bect <jbect>
Submitted:  Mon 02 May 2016 03:52:22 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 28 Dec 2017 06:42:28 PM UTC, comment #5: 

I tried Mike's example code from comment #1 and this now passes on the development branch.  This is probably due to significant refactoring of the symbol table by jwe.  Mariking as fixed and closing report.

Rik <rik5>
Group administrator
Tue 03 May 2016 01:58:58 PM UTC, comment #4: 

After having spent some more time on bug #35881, I believe that this one is different.

Julien Bect <jbect>
Tue 03 May 2016 11:36:51 AM UTC, comment #3: 

Yes, I agree this is similar to bug #35881.

But I wouldn't mark it as duplicate:

  • in bug #35881, clear is called from within a function that has subfunctions.


  • in this bug, clear is called from the base workspace (but a handle to a function that has subfunctions is saved somewhere in an mlock'ed persistent).
Julien Bect <jbect>
Mon 02 May 2016 06:31:41 PM UTC, comment #2: 

And after that narrowing down, this actually looks a lot like bug #35881, what do you think?

Mike Miller <mtmiller>
Group Member
Mon 02 May 2016 06:28:31 PM UTC, comment #1: 

Confirmed, this bug actually needs a handle to a function that references a subfunction, which is why the error you see is about "empty_cf" not about "sqp".

Here is a simple demonstrator:


$ cat bug47828.m
function bug47828 ()

  persistent func;
  if (isempty (func))
    func = @myfunc;
    mlock ();
  endif

  func ();

endfunction

$ cat myfunc.m
function myfunc ()
  disp ("myfunc");
  myinnerfunc ();
endfunction

function myinnerfunc ()
  disp ("myinnerfunc");
endfunction



Mike Miller <mtmiller>
Group Member
Mon 02 May 2016 03:52:22 PM UTC, original submission:  

Consider the following m-file


function toto ()

persistent f
if isempty (f)
  disp Init
  f = @sqp;
  mlock
endif

f (0, @(x) (x - 1).^2)

endfunction


Then the following sequence of instruction leads to an error:

>> toto
Init
ans =  1.00000

>> toto
ans =  1.00000

>> clear all

>> toto
error: @empty_cf: no function and no method found
error: called from
    sqp at line 227 column 10
    toto at line 10 column 1


The handle to sqp stored in the persistent variable f appears to be "corrupted" by clear.

Julien Bect <jbect>

 

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

Attach Files:
   
   
Comment:
   

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 rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by jbect (Submitted the item)
  •  

    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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-12-28 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-05-02 mtmiller CategoryNone Interpreter
        StatusNone Confirmed
        Release4.0.2 dev
        SummaryProblement with persistent handle and &quot;clear all&quot; persistent handle to function with subfunction fails after "clear all"

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code