Tue 14 Nov 2017 01:44:43 AM UTC, comment #6:
The problem seems to be very subtle. The xtype and data pointer for the B matrix are set by this code.
Later on within the SuiteSparse library there is an if test on this codition
The problem occurs when the Sparse matrix is empty. In this case, because there is no data to store, the data pointer is NULL. That causes SuiteSparse to eventually fail. Apparently this problem has been encountered before. The test for rows or columns less than one looks like it is designed to find empty matrices, and replace the nullptr with a dummy pointer to a valid region.
I replaced the code above with
This works and the code no longer segfaults. The question is whether this is okay in all situations. I think it is, but I'm adding jwe to the CC list so he can comment on this change.
If it is okay, it should be implemented in 4 different instances in dSparse.cc and 4 more in CSparse.cc on the stable branch. On the default branch, the comparison to 0x0 should be replaced with a comparison to nullptr.
|
Fri 10 Nov 2017 04:12:42 PM UTC, comment #4:
Here is a backtrace:
#0 0x00007ffff5ef08a5 in SparseMatrix::fsolve (this=0x7fffffffaf80, mattype=..., b=..., err=@0x7fffffffae48: 0,
rcond=@0x7fffffffae40: 0.036477512569622478, sing_handler=0x7ffff77e5707 <solve_singularity_warning(double)>,
calc_cond=true) at ../liboctave/array/dSparse.cc:6064
#1 0x00007ffff5ef3b86 in SparseMatrix::solve (this=0x7fffffffaf80, mattype=..., b=..., err=@0x7fffffffae48: 0,
rcond=@0x7fffffffae40: 0.036477512569622478, sing_handler=0x7ffff77e5707 <solve_singularity_warning(double)>,
singular_fallback=true) at ../liboctave/array/dSparse.cc:6831
#2 0x00007ffff77e702d in xleftdiv (a=..., b=..., typ=...) at ../libinterp/corefcn/sparse-xdiv.cc:495
#3 0x00007ffff705b738 in oct_binop_ldiv (a1=..., a2=...) at ../libinterp/operators/op-sm-sm.cc:122
#4 0x00007ffff72cc69b in do_binary_op (op=octave_value::op_ldiv, v1=..., v2=...) at ../libinterp/octave-value/ov.cc:2186
#5 0x00007ffff738f1aa in octave::tree_evaluator::visit_binary_expression (this=0x62f130, expr=...)
at ../libinterp/parse-tree/pt-eval.cc:232
#6 0x00007ffff7388fc8 in octave::tree_binary_expression::accept (this=0x7de190, tw=...)
at ../libinterp/parse-tree/pt-binop.h:110
#7 0x00007ffff721ddfa in octave::tree_evaluator::evaluate (this=0x62f130, expr=0x7de190, nargout=1)
at ../libinterp/parse-tree/pt-eval.h:271
#8 0x00007ffff7396ed0 in octave::tree_evaluator::visit_simple_assignment (this=0x62f130, expr=...)
at ../libinterp/parse-tree/pt-eval.cc:2087
#9 0x00007ffff7388950 in octave::tree_simple_assignment::accept (this=0x7de1d0, tw=...)
at ../libinterp/parse-tree/pt-assign.h:83
#10 0x00007ffff721ddfa in octave::tree_evaluator::evaluate (this=0x62f130, expr=0x7de1d0, nargout=0)
at ../libinterp/parse-tree/pt-eval.h:271
#11 0x00007ffff739772d in octave::tree_evaluator::visit_statement (this=0x62f130, stmt=...)
at ../libinterp/parse-tree/pt-eval.cc:2211
#12 0x00007ffff73baee0 in octave::tree_statement::accept (this=0x7de210, tw=...) at ../libinterp/parse-tree/pt-stmt.h:112
#13 0x00007ffff73978ba in octave::tree_evaluator::visit_statement_list (this=0x62f130, lst=...)
at ../libinterp/parse-tree/pt-eval.cc:2253
#14 0x00007ffff721e234 in octave::tree_statement_list::accept (this=0x84db20, tw=...) at ../libinterp/parse-tree/pt-stmt.h:187
#15 0x00007ffff72b3229 in octave_user_script::call (this=0x7f5400, tw=..., nargout=0, args=...)
at ../libinterp/octave-value/ov-usr-fcn.cc:216
---Type <return> to continue, or q <return> to quit---
#16 0x00007ffff73921e8 in octave::tree_evaluator::visit_identifier (this=0x62f130, expr=...)
at ../libinterp/parse-tree/pt-eval.cc:1010
#17 0x00007ffff7371636 in octave::tree_identifier::accept (this=0xa1d610, tw=...) at ../libinterp/parse-tree/pt-id.h:128
#18 0x00007ffff721ddfa in octave::tree_evaluator::evaluate (this=0x62f130, expr=0xa1d610, nargout=0)
at ../libinterp/parse-tree/pt-eval.h:271
#19 0x00007ffff739772d in octave::tree_evaluator::visit_statement (this=0x62f130, stmt=...)
at ../libinterp/parse-tree/pt-eval.cc:2211
#20 0x00007ffff73baee0 in octave::tree_statement::accept (this=0x77f0d0, tw=...) at ../libinterp/parse-tree/pt-stmt.h:112
#21 0x00007ffff73978ba in octave::tree_evaluator::visit_statement_list (this=0x62f130, lst=...)
at ../libinterp/parse-tree/pt-eval.cc:2253
#22 0x00007ffff721e234 in octave::tree_statement_list::accept (this=0x80f780, tw=...) at ../libinterp/parse-tree/pt-stmt.h:187
#23 0x00007ffff76b38c0 in octave::interpreter::main_loop (this=0x62ed80) at ../libinterp/corefcn/interpreter.cc:974
#24 0x00007ffff76b2771 in octave::interpreter::execute (this=0x62ed80) at ../libinterp/corefcn/interpreter.cc:695
#25 0x00007ffff6e79973 in octave::cli_application::execute (this=0x7fffffffc4b0) at ../libinterp/octave.cc:384
#26 0x000000000040184a in main (argc=9, argv=0x7fffffffc7d8) at ../src/main-cli.cc:90
(gdb)
|
Wed 08 Nov 2017 10:10:17 AM UTC, original submission:
Dear Octave users and developers,
If you run the octave script in the attached file, you get the following output:
$ octave octave_cholmod_sparse.m
warning: warning -4, at line 88 in file /cygdrive/e/cyg_pub/devel/suitesparse/build_4.5.1/cholmod-3.0.9-1.x86_64/src/cholmod-3.0.9/Cholesky/cholmod_spsolve.c: invalid xtype
warning: called from
octave_cholmod_sparse at line 6 column 3
After that octave crashes:
Program received signal SIGSEGV, Segmentation fault.
0x00000003de0f36cb in cygoctave-4!_ZNK12SparseMatrix6fsolveER10MatrixTypeRKS_RiR dPFvdEb () from /usr/bin/cygoctave-4.dll
(gdb) bt full
No symbol table info available.#0 0x00000003de0f36cb in cygoctave-4!SparseMatrix::fsolve(MatrixType&, SparseMatrix const&, int&, double&, void (*)(double), bool) const () from /usr/bin/cygoctave-4.dll
No symbol table info available.
#1 0x00000003de0f90b8 in cygoctave-4!SparseMatrix::solve(MatrixType&, SparseMatrix const&, int&, double&, void (*)(double), bool) const () from /usr/bin/cygoctave-4.dll
No symbol table info available.
#2 0x00000003dd7692e5 in cygoctinterp-4!xleftdiv(SparseMatrix const&, SparseMatrix const&, MatrixType&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#3 0x00000003dd1714de in cygoctinterp-4!install_sm_sm_ops() () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#4 0x00000003dd35bbb0 in cygoctinterp-4!do_binary_op(octave_value::binary_op, octave_value const&, octave_value const&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#5 0x00000003dd3a9166 in cygoctinterp-4!tree_binary_expression::rvalue1(int) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#6 0x00000003dd3a4f36 in cygoctinterp-4!tree_simple_assignment::rvalue1(int) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#7 0x00000003dd3b4122 in cygoctinterp-4!octave::tree_evaluator::visit_statement(tree_statement&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#8 0x00000003dd3b38a9 in cygoctinterp-4!octave::tree_evaluator::visit_statement_list(tree_statement_list&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#9 0x00000003dd352567 in cygoctinterp-4!octave_user_script::do_multi_index_op(int, octave_value_list const&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#10 0x00000003dd39cc77 in cygoctinterp-4!source_file(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#11 0x00000003dd6551a3 in cygoctinterp-4!recover_from_exception() () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#12 0x00000003dd6562c6 in cygoctinterp-4!octave::interpreter::execute_command_line_file(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#13 0x00000003dd65b2eb in cygoctinterp-4!octave::interpreter::execute() () from /usr/bin/cygoctinterp-4.dll
No symbol table info available.
#14 0x0000000100401913 in ?? ()
No symbol table info available.
#15 0x0000000180047812 in _cygwin_exit_return () from /usr/bin/cygwin1.dll
No symbol table info available.
#16 0x00000001800455e3 in _cygtls::call2(unsigned int ()(void, void), void, void*) () from /usr/bin/cygwin1.dll
No symbol table info available.
#17 0x0000000180045694 in _cygtls::call(unsigned int ()(void, void), void) () from /usr/bin/cygwin1.dll
No symbol table info available.
#18 0x0000000000000000 in ?? ()
No symbol table info
available.
This bug also occurs in the native Windows build version 4.0.0 and 4.2.1.
|