bugGNU Octave - Bugs: bug #53507, Sparse.h:491:57: runtime error:...

 
 

bug #53507: Sparse.h:491:57: runtime error: load of value 176, which is not a valid value for type 'bool'

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Wed 28 Mar 2018 09:34:16 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 29 Mar 2018 03:55:42 PM UTC, comment #8: 

I fixed the problem here (http://hg.savannah.gnu.org/hgweb/octave/rev/e376a35f168f).  Mike was correct that the transpose was reading the data before the data had been set to true.  It only required re-ordering the transpose and fill operations.

Rik <rik5>
Group administrator
Thu 29 Mar 2018 03:32:50 PM UTC, comment #7: 

It is definitely symbfact.cc that is the problem.  And only when you ask for the 5 output argument which creates a SparseBoolMatrix.

I already found one problem which is that the wrong constructor is called.  In boolSparse.h there is


  explicit SparseBoolMatrix (octave_idx_type r, octave_idx_type c, bool val)
    : Sparse<bool> (r, c, val) { }

  SparseBoolMatrix (const dim_vector& dv, octave_idx_type nz = 0)
    : Sparse<bool> (dv, nz) { }


Symbfact is calling


      SparseBoolMatrix L (n, n, lnz);


It appears that the original author believed there was a constructor that accepted row, column, and nnz.  Instead, they were calling row, column, val.  Since lnz was presumably greater than zero this would be converted to the bool value true and the array filled with true.

I made this change


-      SparseBoolMatrix L (n, n, lnz);
+      SparseBoolMatrix L (dim_vector (n, n), lnz);


, but the warning message is still there.  I will take a look further.

Rik <rik5>
Group administrator
Thu 29 Mar 2018 05:27:27 AM UTC, comment #6: 

I'm no expert on the Sparse type, but it looks to me like symbfact isn't populating the data array until the very end. Until then it's completely uninitialized. It might be the transpose on line 338 that is copying uninitialized bool values from one data array to another (https://hg.savannah.gnu.org/hgweb/octave/file/135cc24efe4c/libinterp/dldfcn/symbfact.cc#l336) before the data is actually filled in on line 342.

Mike Miller <mtmiller>
Group Member
Thu 29 Mar 2018 04:29:12 AM UTC, comment #5: 

I think this is symbfact messing things up.  The code is directly manipulating the sparse matrix representation which looks suspect.

Rik <rik5>
Group administrator
Thu 29 Mar 2018 12:39:01 AM UTC, comment #4: 

For completion sake.

This one works


octave:1> A = sparse (magic (3));
octave:2>  [~, ~, ~, ~, l] = symbfact (A, "sym", "lower");


this one has the same problem:


octave:1> A = sparse ([1 0 8;0 1 8;8 8 1]);
octave:2> [count, h, parent, post, r] = symbfact (A);
../liboctave/array/Sparse.h:491:57: runtime error: load of value 48, which is not a valid value for type 'bool'


This is the only problem I observed with -fsanitize=undefined.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 29 Mar 2018 12:30:22 AM UTC, comment #3: 

Actually, doing this test line by line:


octave:1> A = sparse (magic (3));
octave:2>  [count, h, parent, post, r] = symbfact (A);
../liboctave/array/Sparse.h:491:57: runtime error: load of value 208, which is not a valid value for type 'bool'


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 29 Mar 2018 12:25:02 AM UTC, comment #2: 


octave:1> test ("libinterp/dldfcn/symbfact.cc-tst", "verbose")
>>>>> /home/dima/src/octave/gcc_usan/libinterp/dldfcn/symbfact.cc-tst
***** testif HAVE_CHOLMOD
 A = sparse (magic (3));
 [count, h, parent, post, r] = symbfact (A);
 assert (count, [3; 2; 1]);
 assert (h, 3);
 assert (parent, [2; 3; 0]);
 assert (r, sparse (triu (true (3))));
../liboctave/array/Sparse.h:491:57: runtime error: load of value 128, which is not a valid value for type 'bool'
***** testif HAVE_CHOLMOD
 ## Test MODE "lower"
 A = sparse (magic (3));
 [~, ~, ~, ~, l] = symbfact (A, "sym", "lower");
 assert (l, sparse (tril (true (3))));
***** testif HAVE_CHOLMOD <*42587>
 ## singular matrix
 A = sparse ([1 0 8;0 1 8;8 8 1]);
 [count, h, parent, post, r] = symbfact (A);
***** testif HAVE_CHOLMOD
 fail ("symbfact ()");
 fail ("symbfact (1,2,3,4)");
 fail ("symbfact ({1})", "wrong type argument 'cell'");
 fail ("symbfact (sparse (1), {1})", "TYP must be a string");
 fail ("symbfact (sparse (1), 'foobar')", 'unrecognized TYP "foobar"');
 fail ("symbfact (sparse (1), 'sym', {'L'})", "MODE must be a string");
 fail ('symbfact (sparse (1), "sym", "foobar")', 'unrecognized MODE "foobar"');
 fail ("symbfact (sparse ([1, 2; 3, 4; 5, 6]))", "S must be a square matrix");
PASSES 4 out of 4 tests
octave:2> __octave_config_info__ ("hg_id")
ans = a4c687fec320


Interestingly, if I run it again (in the same octave session) -- there is no error any more.


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Wed 28 Mar 2018 11:14:59 PM UTC, comment #1: 

There aren't that many tests in symbfact.cc.  With the version you build that has -fsanitize enabled, could you just run the tests one by one in a terminal window and see which one is failing?


%!testif HAVE_CHOLMOD
%! A = sparse (magic (3));
%! [count, h, parent, post, r] = symbfact (A);
%! assert (count, [3; 2; 1]);
%! assert (h, 3);
%! assert (parent, [2; 3; 0]);
%! assert (r, sparse (triu (true (3))));

%!testif HAVE_CHOLMOD
%! ## Test MODE "lower"
%! A = sparse (magic (3));
%! [~, ~, ~, ~, l] = symbfact (A, "sym", "lower");
%! assert (l, sparse (tril (true (3))));

%!testif HAVE_CHOLMOD <*42587>
%! ## singular matrix
%! A = sparse ([1 0 8;0 1 8;8 8 1]);
%! [count, h, parent, post, r] = symbfact (A);

## Test input validation
%!testif HAVE_CHOLMOD
%! fail ("symbfact ()");
%! fail ("symbfact (1,2,3,4)");
%! fail ("symbfact ({1})", "wrong type argument 'cell'");
%! fail ("symbfact (sparse (1), {1})", "TYP must be a string");
%! fail ("symbfact (sparse (1), 'foobar')", 'unrecognized TYP "foobar"');
%! fail ("symbfact (sparse (1), 'sym', {'L'})", "MODE must be a string");
%! fail ('symbfact (sparse (1), "sym", "foobar")', 'unrecognized MODE "foobar"');
%! fail ("symbfact (sparse ([1, 2; 3, 4; 5, 6]))", "S must be a square matrix");



Rik <rik5>
Group administrator
Wed 28 Mar 2018 09:34:16 PM UTC, original submission:  

octave 4.3.0+
hg id
63f17bf9932a (stable) tip

compiked with gcc 7.3.1 / -O2 -fsanitize=undefined

running make check gives:


libinterp/dldfcn/symbfact.cc-tst ............................../liboctave/array/Sparse.h:491:57: runtime error: load of value 176, which is not a valid value for type 'bool'
 PASS      4/4
  libinterp/octave-value/ov-base.cc-tst ....................... PASS      1/1


Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

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 mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dasergatskov (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-29 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code