octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #56232] Octave crash when inverting an empty s


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #56232] Octave crash when inverting an empty sparse matrix.
Date: Tue, 7 May 2019 16:19:08 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

Follow-up Comment #28, bug #56232 (project octave):

After seeing comment #16, I built umfpackmex from UMFPACK for Octave.  If I
call it with


[l, u, p, q] = umfpackmex (sparse (2, 2, 0))


then it errors with the symbolic factorization failed message.  As David says
in comment #18, this failure can happen if Ai or Ap are not allocated.  So
just before the call to umfpack_dl_qsymbolic, I added


   if (!Ai)
      Ai = (Long *) malloc (0);


and then it works with both Ap and Ai valid pointers and it returns the
following result:


octave:1> [l, u, p, q] = umfpackmex (sparse (2, 2, 0))
l =

Compressed Column Sparse (rows = 2, cols = 2, nnz = 2 [50%])

  (1, 1) ->  1
  (2, 2) ->  1

u =

Compressed Column Sparse (rows = 2, cols = 2, nnz = 0 [0%])


p =

Compressed Column Sparse (rows = 2, cols = 2, nnz = 2 [50%])

  (1, 1) ->  1
  (2, 2) ->  1

q =

Compressed Column Sparse (rows = 2, cols = 2, nnz = 2 [50%])

  (2, 1) ->  1
  (1, 2) ->  1


I would also prefer if we didn't have to allocate arrays that will never be
used (because NNZ is zero, for example, or the size or the sparse array is
0x0) but I also found that mxGetJc and mxGetIr are documented to return NULL
on error but it looks like they should return valid pointers otherwise, even
if the lengths of the arrays the point to are zero.  We could arrange for
Octave's mxGetJc and mxGetIr functions to fake that behavior, but it might be
easiest if we always allocated them in Octave's internals as well, even if
there are no elements in the sparse array.

It seems that UMFPACK also will fail if the data pointer is NULL.

The attached change seems to work for me.



(file #46877)
    _______________________________________________________

Additional Item Attachment:

File name: sparse-diffs.txt               Size:1 KB
    <https://savannah.gnu.org/file/sparse-diffs.txt?file_id=46877>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56232>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]