bugGNU Octave - Bugs: bug #64696, Failure to load sparse matrix with...


bug #64696: Failure to load sparse matrix with no nonzero elements from text file saved by Octave

Submitter:  John W. Eaton <jwe>
Submitted:  Tue 19 Sep 2023 05:30:44 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 8.3.0 Operating System:  * Any
Fixed Release:  8.4.0 Planned Release:  8.4.0
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Fri 13 Oct 2023 07:29:09 PM UTC, comment #6: 

No problems reported in a couple of weeks. Closing as fixed.

Arun Giridhar <arungiridhar>
Group Member
Fri 29 Sep 2023 12:11:42 PM UTC, comment #5: 

I pushed your change to the stable branch here:

Markus Mützel <mmuetzel>
Group administrator
Sun 24 Sep 2023 04:20:04 PM UTC, comment #4: 

I wasn't aware that these files are meant to be installed.

In case users are meant to be able to instantiate these templates with more types, we might need to put some `extern template` declarations somewhere to avoid that the user code (inadvertently) implicitly instantiates the templates with the same types for which we'd like to use symbols from liboctinterp. (That could potentially mess with specializations.)

I haven't checked for all symbols whether there are some which are defined in the "template declaration file" (e.g., ov-base-diag.cc) or in the header (e.g., ov-base-diag.h) and which are specialized in the "template instantiation file" (e.g., ov-cx-diag.cc). (I don't know if differing vtables could be an issue. ISTR to have had some trouble with the Array<T> template regarding that.)
Anyway, that could be part of another change. And it might not be necessary at all.

All in all, your change looks good to me. 👍
Imho, it can be pushed to stable.

Markus Mützel <mmuetzel>
Group administrator
Wed 20 Sep 2023 05:08:53 PM UTC, comment #3: 

Thanks for noticing.  Your fix seems OK, but I also see that the template source files from libinterp are not installed along with the corresponding headers as are the similar template source files from liboctave.  So how about the attached change instead?

(file #55148)

John W. Eaton <jwe>
Group administrator
Wed 20 Sep 2023 01:14:21 PM UTC, comment #2: 

No tests seem to be extracted from that file.
That is probably because the `ov-base-*.cc` files are excluded from `OCTAVE_VALUE_SRC` in libinterp/octave-value/module.mk.

Does the following change (untested) look reasonable?

diff -r 557f0edeb210 libinterp/module.mk
--- a/libinterp/module.mk        Fri Sep 08 16:30:48 2023 +0200
+++ b/libinterp/module.mk        Wed Sep 20 15:13:41 2023 +0200
@@ -105,6 +105,7 @@
 DIST_SRC += \
   %reldir%/octave.cc \
+  $(libinterp_EXTRA_DIST) \

Markus Mützel <mmuetzel>
Group administrator
Tue 19 Sep 2023 06:34:04 PM UTC, comment #1: 

I pushed the following change to stable and merged with default:


John W. Eaton <jwe>
Group administrator
Tue 19 Sep 2023 05:30:44 PM UTC, original submission:  

I see the following behavior with 8.3.0:

octave:1> version
ans = 8.3.0
octave:2> x = y = sparse (1, 2);
octave:3> save tmp.dat x y
octave:4> fileread ("tmp.dat")
ans = # Created by Octave 8.3.0, Tue Sep 19 13:02:42 2023 EDT <jwe@devtty>
# name: x
# type: sparse matrix
# nnz: 0
# rows: 1
# columns: 2

# name: y
# type: sparse matrix
# nnz: 0
# rows: 1
# columns: 2

octave:5> load tmp.dat
error: invalid sparse matrix: element 1: Symbols '#' is not an integer format

I will commit a fix with an explanation of why the problem happens after I have a bug report number.

John W. Eaton <jwe>
Group administrator


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

Attach Files:

Attached Files
file #55148:  template-src.cset added by jwe (2KiB - 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 arungiridhar (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by jwe (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-13 arungiridhar StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2023-09-20 jwe Attached File- Added template-src.cset, #55148
    2023-09-19 jwe StatusNone Ready For Test
    2023-09-19 jwe Fixed ReleaseNone 8.4.0

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code