[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #54527] Crash when concatenating empty element
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #54527] Crash when concatenating empty elements with sparse matrices. |
Date: |
Fri, 17 Aug 2018 15:58:52 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0 |
Follow-up Comment #4, bug #54527 (project octave):
The problem seems to be in Sparse.cc with the cat function.
There is this bit of code which is designed to handle concatenating empty
matrices
const Sparse<T>& spi = sparse_list[i];
// Skipping empty matrices. See the comment in Array.cc.
if (spi.isempty ())
continue;
Using gdb, I get
(gdb) display-sparse-array spi
sparse object: (const Sparse<double> &) @0x1fe7f10: {
_vptr.Sparse = 0x7f33ae18d5b0 <vtable for SparseMatrix+16>, rep = 0x2277af0,
dimensions = {rep = 0x1fcff50}}
dimensions.rep[0] = ndims: 2
dims: {1, 0}
dimensions.rep[1] = 0
rep = {d = 0x0, r = 0x0, c = 0x1ff4770, nzmx = 0, nrows = 1, ncols = 0, count
= {
count = 1}}
rep.d = Invalid number 0 of repetitions.
(gdb) p spi.isempty ()
$3 = false
(gdb) p spi.numel ()
$4 = 0
The killer is that isempty () is returning false for this very empty matrix.
Looking at isempty in Sparse.h I find
bool isempty (void) const { return (rows () < 1 && cols () < 1); }
That looks very suspect. I think '&&' should be '||' in this case. Or maybe
we should just do things the way we do in Array.h
Array.h: bool isempty (void) const { return numel () == 0; }
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?54527>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/