bugGNU Octave - Bugs: bug #37095, Segfault when calling chol () on...

 
 

bug #37095: Segfault when calling chol () on non-SPD sparse matrix and requesting a second output argument

Submitter:  Guillaume <gyom>
Submitted:  Tue 14 Aug 2012 03:44:54 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  jordigh
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 16 Aug 2012 03:46:00 PM UTC, comment #7: 

Okay, I pushed the fix:

http://hg.savannah.gnu.org/hgweb/octave/rev/82d51d6e470c

It's on the default branch, because it seems to be a relatively rare edge case and I wasn't confident enough to apply it to the stable branch. So it will see the light of day by Octave 3.8.

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Wed 15 Aug 2012 03:21:29 PM UTC, comment #6: 

Works fine, thanks!

Guillaume <gyom>
Wed 15 Aug 2012 02:26:43 PM UTC, comment #5: 

Okay, how about the revised patch?

(file #26362)

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Wed 15 Aug 2012 12:09:59 PM UTC, comment #4: 

Many thanks for looking into this, Jordi.

The patch seems to work for me (ie no segfault and the second output argument prevents an error to be triggered) but there are still warning messages that are displayed:

warning: warning 1, at line 432 in file ../Cholesky/t_cholmod_rowfac.c
warning: not positive definite
warning: warning 1, at line 613 in file ../Supernodal/t_cholmod_super_numeric.c
warning: matrix not positive definite


They are redundant with the information given by the second output argument so they could be removed (MATLAB does not display any).

Guillaume <gyom>
Tue 14 Aug 2012 07:58:52 PM UTC, comment #3: 

Okay, so the issue is that the Octave code stops computation prematurely if the cholmod library flags the matrix as not positive definite, and as part of those computations it's supposed to set the Lsparse pointer to a nonzero value. When it doesn't do that but the return values are requested anyways, it attempts to dereference a null pointer and segfaults.

My patch attached here is an attempt to test if more than output argument is requested, and to plod along even if the matrix fails to be positive definite and return whatever value cholmod thought should be returned.

If there are no complaints with this patch for a few days, I'll push it.



(file #26361)

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Tue 14 Aug 2012 04:27:10 PM UTC, comment #2: 

This seems like an easy fix, working on it...

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Tue 14 Aug 2012 04:25:26 PM UTC, comment #1: 

Hi I can confirm the bug on a recent build,
I changed the title to specify that the crash occurs
only if the input matrix is sparse.

Thanks for the report,
c.

Carlo de Falco <cdf>
Group Member
Tue 14 Aug 2012 03:44:54 PM UTC, original submission:  

Calling CHOL on a non positive definite sparse matrix and two output arguments generates a segmentation fault:

octave:1> A=-speye(3);
octave:2> B=chol(A);
warning: warning 1, at line 432 in file ../Cholesky/t_cholmod_rowfac.c
warning: not positive definite
error: chol: input matrix must be positive definite
octave:2> [B,C]=chol(A);
warning: warning 1, at line 432 in file ../Cholesky/t_cholmod_rowfac.c
warning: not positive definite
panic: Segmentation fault -- stopping myself...
attempting to save variables to `octave-workspace'...
save to `octave-workspace' complete
Segmentation fault


Guillaume <gyom>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #26362:  cholmod.patch added by jordigh (5KiB - text/x-diff)
file #26361:  cholmod.patch added by jordigh (4KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by cdf (Posted a comment)
  • -email is unavailable- added by gyom (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
    2012-08-16 jordigh StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2012-08-15 jordigh Attached File- Added cholmod.patch, #26362
    2012-08-14 jordigh Attached File- Added cholmod.patch, #26361
        StatusConfirmed Patch Submitted
    2012-08-14 jordigh Assigned toNone jordigh
    2012-08-14 cdf StatusNone Confirmed
        SummarySegfault with CHOL and a second output argument Segfault when calling chol () on non-SPD sparse matrix and requesting a second output argument

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code