bugGNU Octave - Bugs: bug #33456, Function handles save()ed with...

 
 

bug #33456: Function handles save()ed with "-binary" can't always be re-load()ed

Submitter:  Olaf Till <i7tiol>
Submitted:  Wed 01 Jun 2011 07:51:56 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Olaf Till Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 14 Jun 2011 07:31:56 PM UTC, comment #5: 

I'm bringing up the discussion of the correct branch for this patch on the Octave maintainers mailing list.

Rik <rik5>
Group administrator
Wed 08 Jun 2011 10:47:01 AM UTC, comment #4: 

Thanks. But shouldn't this go rather (or also) into the stable branch?

Olaf Till <i7tiol>
Group Member
Tue 07 Jun 2011 03:28:13 AM UTC, comment #3: 

Thanks for the patch.  I verified it worked for me and have committed it in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/65b7ce254ba3)

Rik <rik5>
Group administrator
Thu 02 Jun 2011 02:57:39 PM UTC, comment #2: 

The reason is that the "load_binary()" function of function-handles uses std::istream::get(). I din't find it documented, but according to a test "stream.get (char *c, int n)" or "stream.get (char *c, int n, char b)", though loading n - 1 bytes into c as expected, cause stream.eof() to be true if the last read byte was the last byte of the file (i.e. without any trying to read over the file end --- weird). Luckily function-handles seem to be the only octave_values which use std::istream::get() in load_binary().

A changeset is attached which should fix this.


(file #23495)

Olaf Till <i7tiol>
Group Member
Thu 02 Jun 2011 12:00:12 AM UTC, comment #1: 

Confirmed.

In particular, the following formats do save function handles: '-text', '-hdf5'.

The following formats do not accept function handles for saving at all: '-ascii', 'Matlab'

And lastly, '-binary' accepts function handles but doesn't actually save them.


Rik <rik5>
Group administrator
Wed 01 Jun 2011 07:51:56 PM UTC, original submission:  

Release: stable branch, revision 5bf8af73fc34 of 01/06/2011 17:53

Description: Function handles save()ed with "-binary" can't always be re-load()ed.

Repeat by:

octave:1> a = @ sin
a = @sin
octave:2> save ("-binary", "testdata.dat", "a")
octave:3> clear a
octave:4> load ("testdata.dat")
octave:5> a
error: `a' undefined near line 5 column 1

Note that it also doesn't work if the handle is a structure field:

octave:5> a.b = @ sin
a =

  scalar structure containing the fields:

    b = @sin

octave:6> save ("-binary", "testdata.dat", "a")
octave:7> clear a
octave:8> load ("testdata.dat")
octave:9> a
error: `a' undefined near line 9 column 1

But it does work if there is a different structure field (no handle) present:

octave:9> a.b = @ sin
a =

  scalar structure containing the fields:

    b = @sin

octave:10> a.c = 1
a =

  scalar structure containing the fields:

    b = @sin
    c =  1

octave:11> save ("-binary", "testdata.dat", "a")
octave:12> clear a
octave:13> load ("testdata.dat")
octave:14> a
a =

  scalar structure containing the fields:

    b = @sin
    c =  1


Olaf Till <i7tiol>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #23495:  fcn-handle-load-binary.changeset added by i7tiol (1KiB - application/octet-stream)

 

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 i7tiol (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-06-07 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2011-06-02 i7tiol Attached File- Added fcn-handle-load-binary.changeset, #23495
    2011-06-02 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code