bugGNU Octave - Bugs: bug #57941, Handle to a nested function with...

 
 

bug #57941: Handle to a nested function with more than one input does not work

Submitted by:  Marco Caliari <caliari>
Submitted on:  Mon 02 Mar 2020 03:23:37 PM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error
Status:  Confirmed Assigned to:  John W. Eaton <jwe>
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Tue 03 Mar 2020 07:47:09 AM UTC, comment #3: 

Hi, i hope this fix will be applied to Octave 6.1 already?

Stephan Gebauer <stephan_ii>
Mon 02 Mar 2020 08:04:54 PM UTC, comment #2: 

I see the problem now.  The context for closures is not being stored correctly unless the function handle/closure is returned from the function where it is created.  So if you write

function [fh1, fh2] = test_hnf (A)
  fh1 = @nested1;
  function z = nested1 (x)
    z = A * x;
  end
  fh2 = @nested2;
  function z = nested2 (x,y)
    z = A * x .* y;
  end
end

and then use it as

[fh1, fh2] = test_hnf (1);
quad (fh1, 0, 1)
quad2d (fh2, 0, 1, 0, 1)

it will work as expected.

I'm working on a fix.

Thanks for reporting this problem.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Mon 02 Mar 2020 05:15:32 PM UTC, comment #1: 

This looks like an error in the way offsets to values in the call stack are managed when calling nested functions through handles.  Possibly the context for closure frames is not being set correctly?  I'm looking at it.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Mon 02 Mar 2020 03:23:37 PM UTC, original submission:  

Dear all, if you call the attached file with

test_hnf(1)

you see that the handle to nested1 (with one input parameter) works, while the handle to nested2 (with two input parameters) gives

error: 'A' undefined near line 8, column 8
error: called from
    test_hnf>nested2 at line 8 column 7
    quad2d>tensorproduct at line 408 column 5
    quad2d at line 305 column 41
    test_hnf at line 6 column 3

The bug is maybe related to bug #48086.

Marco Caliari <caliari>
Project Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #48534:  test_hnf.m added by caliari (185B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by stephan_ii (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by caliari (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-02 jwe StatusNone => Confirmed
        Assigned toNone => jwe
    2020-03-02 caliari Attached File- => Added test_hnf.m, #48534

    Back to the top


    Powered by Savane 3.5