bugGNU Octave - Bugs: bug #33857, Saved struct with function handle...

 
 

bug #33857: Saved struct with function handle fails to load

Submitted by:  Juan Pablo Carbajal <juanpi>
Submitted on:  Mon 25 Jul 2011 06:24:01 PM UTC  
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  JuanPi Open/Closed:  Closed
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.

 

( Jump to the original submission)

Wed 31 Oct 2012 05:18:33 AM UTC, comment #6: 

I applied Max's patch on the development branch.  I wasn't certain enough of any unintended consequences to apply it to the stable branch.  It is available in Mercurial with any revision >= 15572:859c8bf6d134.  It will show up in the next major release (3.8) as well.

Rik <rik5>
Project Administrator
Tue 30 Oct 2012 01:18:53 PM UTC, comment #5: 

Hi,
In relation to
http://octave.1599824.n4.nabble.com/bug-loading-a-workspace-tt4645891.html

We tested that patch during OctConf12. It passes the tests provided in this bug report.

There are other related bugs that maybe affected with this patch

https://savannah.gnu.org/bugs/?func=detailitem&item_id=36686
https://savannah.gnu.org/bugs/?func=detailitem&item_id=33458
https://savannah.gnu.org/bugs/?func=detailitem&item_id=33456

Juan Pablo Carbajal <juanpi>
Project Member
Thu 19 Jul 2012 09:07:06 PM UTC, comment #4: 

The problem was that the first time a function is run, hidden variables are inserted. This caused problems when loading. The attached patch ignores hidden variables when saving function handles (and core dumps).

(file #26226)

Max Brister <fisheater>
Tue 08 Nov 2011 09:21:54 PM UTC, comment #3: 

Pinging this bug.
Still in dev

708e4224c424 (stable)

I will see if I can work on this...seems rather complicated though.

Juan Pablo Carbajal <juanpi>
Project Member
Sat 17 Sep 2011 02:21:16 AM UTC, comment #2: 

I got the format wrong. Trying again.

clear all
func = @ (x) x;
func (0);
save temp.dat
clear all
load temp.dat

The content of file "temp.dat" is below.

# Created by Octave 3.5.0+, Fri Sep 16 21:56:29 2011 EDT
<bpabbott@Bens-MacBook-Pro.local>
# name: ans
# type: scalar
0


# name: func
# type: function handle
@<anonymous>
@(x) x
# length: 3
# name: .argn.
# type: cell
# rows: 1
# columns: 1
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1
0





# name: .nargin.
# type: scalar
1


# name: .nargout.
# type: scalar
0

Ben Abbott <bpabbott>
Project Member
Sat 17 Sep 2011 02:05:14 AM UTC, comment #1: 

I've confirmed the bug, and simplified the example

Ben Abbott <bpabbott>
Project Member
Mon 25 Jul 2011 06:24:01 PM UTC, original submission:  

Hi,
The following code produces the error

0> n=2;
1> A.func=@(t_,x_,opt_)t_.^n;
2> A.func(0,0,0);
3> save('temp.dat','A');
4> clear all
5> load('temp.dat')
error: load: bogus identifier `.argn.' found in file `'
error: load: reading file
error: load: reading file
error: load: reading file
error: load: reading file
error: load: internal error loading struct elements
error: load: trouble reading ascii file `temp.dat'
error: load: reading file temp.dat

Nota that is line 2> the one causing the problem since the following code works perfectly.

0> n=2;
1> A.func=@(t_,x_,opt_)t_.^n;
2> save('temp.dat','A');
3> clear all
4> load('temp.dat')

The structure somehow retains the information of the arguments and the function "save" tries to save them.

Thanks,

JPi

Juan Pablo Carbajal <juanpi>
Project Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #26226:  bug33857.patch added by fisheater (2KiB - text/x-patch)

 

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 jordigh (Updated the item)
  • -email is unavailable- added by fisheater (Updated the item)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by juanpi (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-10-31 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2012-10-30 jordigh StatusConfirmed => Patch Submitted
    2012-07-19 fisheater Attached File- => Added bug33857.patch, #26226
    2011-09-17 bpabbott StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.5