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

Submitter:  Olaf Till <i7tiol>
Submitted:  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
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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.
--

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

https://hg.savannah.gnu.org/hgweb/octave/rev/d597dc0a5f74

and merged all of this back onto default.

Mike Miller <mtmiller>
Group Member
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>
Group 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>
Group Member
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:


%!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>
Group Member

 

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

Attach Files:
   
   
Comment:
   

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

 

Depends on the following items: None found

Digest:
   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)
  •  

    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 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.13-f8d8.
    Corresponding source code