bugGNU Octave - Bugs: bug #54319, saving a classdef to a MAT file...

 
 

bug #54319: saving a classdef to a MAT file then loading it crashes Octave

Submitter:  Sébastien Villemot <svillemot>
Submitted:  Mon 16 Jul 2018 04:53:43 PM UTC
   
 
Category:  Interpreter Severity:  4 - Important
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.4.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 20 Jul 2018 03:15:58 AM UTC, comment #3: 

I verified the patch works on the original test case posted in comment #0.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Wed 18 Jul 2018 05:02:15 PM UTC, comment #2: 

Thanks for the patch.

I pushed this change to stable and merged with default:

http://hg.savannah.gnu.org/hgweb/octave/rev/7f6fd47712d0

John W. Eaton <jwe>
Group administrator
Mon 16 Jul 2018 07:20:57 PM UTC, comment #1: 

[Just a little OT:]
Being able to properly read/write classdef objects from/to .mat file is a long-standing wish; there's a maintainers-ML thread on it and also a feature request (bug #45833).
IIRC hdf5 I/O is one of the requirements; there's a patch for that that goes some way that I keep alive (I use it in my own octave builds), see patch #8607.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 16 Jul 2018 04:53:43 PM UTC, original submission:  

Hi,

Assume you have defined the following trivial classdef:

classdef NumValue
   properties
      Number = 1
   end
end


Then the following sequence crashes Octave:

octave:1> a = NumValue()
a =

<object NumValue>

octave:2> save -mat foo.mat a
warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned, including private and protected ones.
warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned, including private and protected ones.
octave:3> load foo.mat
octave-gui: libinterp/octave-value/ov-class.cc:1070: bool octave_class::reconstruct_exemplar(): Assertion `have_ctor' failed.
fatal: caught signal Aborted -- stopping myself...
Aborted


The problem is that Octave tries to reload the object as if it was a legacy class, instead of a classdef.

I attach a draft patch that prevents the crash and make Octave return a struct.

Ideally Octave should rather return a classdef value (see also bug #45833). I would be willing to write such a patch, but I would ideally need some guidance (concerning the complexity of the task and the pitfalls to avoid).

Best,

Sébastien Villemot <svillemot>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #44564:  classdef-mat-load.patch added by svillemot (726B - text/x-patch)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by svillemot (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
    2018-08-06 mtmiller Dependencies- bugs #54455 is dependent
    2018-07-20 rik5 Severity3 - Normal 4 - Important
        StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-07-18 jwe StatusNone Ready For Test
    2018-07-16 svillemot Attached File- Added classdef-mat-load.patch, #44564

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code