bugGNU Octave - Bugs: bug #40305, real (sparse (2i)) creates bad...


bug #40305: real (sparse (2i)) creates bad internally formatted sparse matrix

Submitted by:  Rik <rik5>
Submitted on:  Fri 18 Oct 2013 05:48:45 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  David Bateman <dbateman>
Originator Name:  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 18 Oct 2013 10:48:37 PM UTC, comment #2: 

I backed the temporary fix out 12 minutes after you checked in your fix.

Rik <rik5>
Project Administrator
Fri 18 Oct 2013 09:18:28 PM UTC, comment #1: 

I'm surprised this bug was there since at least 2005 without being seen and fixed as the fix is trivial. See the changeset


Rik, should you backout the changeset 1d41b1910531 as casting a sparse matrix as full isn't really that great an idea as the memory requirement and performance might be significantly degraded.


David Bateman <dbateman>
Project MemberIn charge of this item.
Fri 18 Oct 2013 05:48:45 PM UTC, original submission:  

I just tracked down a segfault in Octave to incorrect behavior of real() for sparse matrices.

Check out the following:

debug> x = sparse (2i)
x = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1 [100%])

  (1, 1) ->  0 + 2i
debug> typeinfo (x)
ans = sparse complex matrix
debug> xr = real (x)
xr = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1 [100%])

  (1, 1) -> 0
debug> typeinfo (xr)
ans = sparse matrix
debug> nnz (xr)
ans =  1

The problem is that the internal format seems to have become corrupted after the call to real which changed a non-zero entry to a zero entry.  nnz() should return 0 after the call to real().

If you try to use this bad matrix in further calculations it can lead to a segfault.  Example:

complex (xr, sparse (1))

Rik <rik5>
Project Administrator


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-18 dbateman StatusNone => Fixed
        Assigned toNone => dbateman
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.7