bugGNU Octave - Bugs: bug #50831, can't load structure with...


bug #50831: can't load structure with non-matlab field identifiers from 'text' format file

Submitted by:  Olaf Till <i7tiol>
Submitted on:  Wed 19 Apr 2017 12:50:49 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Olaf Till 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.


Fri 15 May 2020 04:15:11 PM UTC, comment #5: 

I agree.  I changed the BIST test to use a temporary file in this cset: https://hg.savannah.gnu.org/hgweb/octave/rev/6beb610b3bcd.

Rik <rik5>
Project Administrator
Thu 14 May 2020 10:46:23 PM UTC, comment #4: 

The test for bug-50831.tst has

filename = "save-text.var";

I think it should be a file in /tmp directory.


Dmitri A. Sergatskov <dasergatskov>
Fri 27 Mar 2020 08:16:04 PM UTC, comment #3: 

I grafted this patch onto the stable branch, since it's important to me that feature is fixed in the upcoming version 6.

I also noticed that you neglected to include the new test/bug-50831 directory in the build system, so I did that in a new commit on the stable branch


and merged all of this back onto default.

Mike Miller <mtmiller>
Project Administrator
Sun 15 Mar 2020 09:08:22 PM UTC, comment #2: 

I changed the summary to refer to files in the 'text' format, rather than 'ascii' format.  Octave doesn't support saving struct variables in ascii format, only matrices.

I also reviewed, amended, and checked in Olaf's changeset here https://hg.savannah.gnu.org/hgweb/octave/rev/ef349f5c320b.

The patch was old enough that it it didn't apply cleanly to the current code base so I fixed that up.  I also changed the variable name "string_identifier" to "do_name_validation" so that the code can read naturally as "if (do_name_validation && ...)".

The BIST test was ambiguous in that it used whatever save format was set as the default.  For most users, this would be '-text', so I made that explicit.

Marking bug fixed and closing report.

Rik <rik5>
Project Administrator
Fri 13 Mar 2020 07:24:54 PM UTC, comment #1: 

Hi Olaf, I've tested this patch on the current stable branch, with some minor fixup needed to adapt to changes in the past years, and it works for me. I want to see this applied for version 6 if possible, since this also fixes bug #56368.

I recently learned about bug #46645, which I think is the same exact bug as this one, and there's been more discussion on that one, so I asked for comments on your patch there.

Mike Miller <mtmiller>
Project Administrator
Wed 19 Apr 2017 12:50:49 PM UTC, original submission:  

Contrary to Matlab, Octave allows any strings as field identifiers in structures. But after saving such structures in the 'ascii' format, they can't be reloaded, since the validity of the identifier is checked with a general test for identifier validity.

You can check for this bug with the following test:

%! filename = "test-ascii.dat";
%! a.("a-b") = 1;
%! unwind_protect
%!   save (filename, "a");
%!   la = load (filename);
%!   assert (a, la.a);
%! unwind_protect_cleanup
%!   unlink (filename);
%! end_unwind_protect

A patch will be attached as soon as the bug number is known.

The patch avoids checking of identifier validity whenever function fields are read from an 'ascii' format file. The above test is contained in the changeset.

Olaf Till <i7tiol>
Project Member


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

Attach Files:

Attached Files
file #40444:  bug-50831.cset added by i7tiol (4KiB - application/octet-stream)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by i7tiol (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-27 mtmiller Carbon-CopyRemoved 80942 => -
    2020-03-15 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
        Summarycan't load structure with non-matlab field identifiers from 'ascii' format file => can't load structure with non-matlab field identifiers from 'text' format file
    2019-05-22 mtmiller Dependencies- => bugs #56368 is dependent
    2018-03-20 mtmiller CategoryNone => Octave Function
        StatusNone => Patch Submitted
    2017-04-19 i7tiol Attached File- => Added bug-50831.cset, #40444

    Back to the top

    Powered by Savane 3.7