On 27-Jul-2006, Andy Adler wrote:
| I would say no, although perhaps we should give a warning that
| 2-norms of sparse matries can be very slow.
OK, I would accept a patch for this.
| Also, octave shouldn't crash, of course.
Right, it shouldn't crash anyway. Instead, it should throw a
bad_alloc exception and end up back at the prompt. Unless the
allocation is done with malloc in an external library and the bad
allocation is not caught. I still see
| One more idea: I wonder if it would be possible to predict whether
| a computation will run out of memory. Then we can bail out earlier,
| and not irritate the user by having to wait to not get an answer.
| OTOH, I can see how this would be very difficult.
It's not really possible on a multi-user machine. Someone else can
grab memory from the system in the time between your calculation of
what is available and when you allocate the memory. It's just better
to try to allocate and then throw an exception when it fails. But C
sucks and fails to provide a good way to handle out-of-memory
conditions, other than checking after every call to malloc (or
realloc). So we can't properly handle out-of-memory conditions in
external C libraries unless they are carefully written.
BTW, I still see the following and I don't know why it is happening or
how to fix it. I don't really understand the sparse code, so it would
help if someone else who needs this can help debug it.
octave:1> m = 200;
octave:2> n = m;
octave:3> mn = m*n;
octave:4> A = (spdiag(4*ones(1,mn))
Post by Søren Hauberg- spdiag(ones(1,mn-1), 1)
- spdiag(ones(1,mn-1), -1)
- spdiag(ones(1,mn-m), m)
- spdiag(ones(1,mn-m), -m));
octave:5> cond(A)
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46912589648832 (LWP 15081)]
0x00002aaaaba2b349 in SparseMatrix::matrix_value (this=<value optimized out>)
at /home/jwe/src/octave/liboctave/dSparse.cc:7828
7828 retval.elem (ridx(i), j) = data (i);
Current language: auto; currently c++
(gdb) p ridx
Cannot access memory at address 0x0
(gdb) where
#0 0x00002aaaaba2b349 in SparseMatrix::matrix_value (this=<value optimized out>)
at /home/jwe/src/octave/liboctave/dSparse.cc:7828
#1 0x00002aaaab0c482d in octave_sparse_matrix::matrix_value (this=<value optimized out>)
at /home/jwe/src/octave/src/ov-re-sparse.cc:136
#2 0x00002aaab0eec4f0 in Fsvd (args=<value optimized out>, nargout=1) at /home/jwe/src/octave/src/ov.h:580
#3 0x00002aaaaafef505 in octave_builtin::do_multi_index_op (this=0x14a99d0, nargout=1, args=@0x1804430)
at /home/jwe/src/octave/src/ov-builtin.cc:104
#4 0x00002aaaaafeede6 in octave_builtin::subsref (this=0x14a99d0, type=@0x1852aa8, idx=@0x7fffffefde90,
nargout=1) at /home/jwe/src/octave/src/ov-builtin.cc:54
#5 0x00002aaaaafbc0e7 in octave_value::subsref (this=0x7fffffefdeb0, type=@0x1852aa8, idx=@0x7fffffefde90,
nargout=1) at /home/jwe/src/octave/src/ov.cc:734
#6 0x00002aaaab0e076f in tree_index_expression::rvalue (this=0x1852a70, nargout=1)
at /home/jwe/src/octave/src/pt-idx.cc:352
#7 0x00002aaaab0dfa22 in tree_index_expression::rvalue (this=0x1852a70)
at /home/jwe/src/octave/src/pt-idx.cc:363
#8 0x00002aaaab0cdc82 in tree_simple_assignment::rvalue (this=0x18532d0)
at /home/jwe/src/octave/src/pt-assign.cc:82
#9 0x00002aaaab0ccb9b in tree_simple_assignment::rvalue (this=0x18532d0, nargout=<value optimized out>)
at /home/jwe/src/octave/src/pt-assign.cc:64
#10 0x00002aaaab0f93b4 in tree_statement::eval (this=0x1852a00, silent=<value optimized out>, nargout=0,
in_function_body=false) at /home/jwe/src/octave/src/pt-stmt.cc:133
#11 0x00002aaaab0f9834 in tree_statement_list::eval (this=0x1852090, silent=false, nargout=0)
at /home/jwe/src/octave/src/pt-stmt.cc:190
#12 0x00002aaaab0f6fde in tree_if_clause::eval (this=0x1856140) at /home/jwe/src/octave/src/pt-select.cc:54
#13 0x00002aaaab0f70af in tree_if_command_list::eval (this=0x1850b00)
at /home/jwe/src/octave/src/pt-select.cc:85
#14 0x00002aaaab0f70ef in tree_if_command::eval (this=0x1856b40) at /home/jwe/src/octave/src/pt-select.cc:124
#15 0x00002aaaab0f92db in tree_statement::eval (this=0x1856830, silent=<value optimized out>, nargout=0,
in_function_body=false) at /home/jwe/src/octave/src/pt-stmt.cc:102
#16 0x00002aaaab0f9834 in tree_statement_list::eval (this=0x184c330, silent=false, nargout=0)
at /home/jwe/src/octave/src/pt-stmt.cc:190
---Type <return> to continue, or q <return> to quit---
#17 0x00002aaaab0f6fde in tree_if_clause::eval (this=0x1856bd0) at /home/jwe/src/octave/src/pt-select.cc:54
#18 0x00002aaaab0f70af in tree_if_command_list::eval (this=0x1856bf0)
at /home/jwe/src/octave/src/pt-select.cc:85
#19 0x00002aaaab0f70ef in tree_if_command::eval (this=0x1857020) at /home/jwe/src/octave/src/pt-select.cc:124
#20 0x00002aaaab0f92db in tree_statement::eval (this=0x1857b50, silent=<value optimized out>, nargout=0,
in_function_body=true) at /home/jwe/src/octave/src/pt-stmt.cc:102
#21 0x00002aaaab0f9834 in tree_statement_list::eval (this=0x1857b80, silent=false, nargout=0)
at /home/jwe/src/octave/src/pt-stmt.cc:190
#22 0x00002aaaab00056b in octave_user_function::do_multi_index_op (this=0x14956e8, nargout=0, args=@0x1857950)
at /home/jwe/src/octave/src/ov-usr-fcn.cc:359
#23 0x00002aaaaafff648 in octave_user_function::subsref (this=0x14956e8, type=@0x1627718, idx=@0x7fffffefee40,
nargout=0) at /home/jwe/src/octave/src/ov-usr-fcn.cc:220
#24 0x00002aaaaafbc0e7 in octave_value::subsref (this=0x7fffffefee60, type=@0x1627718, idx=@0x7fffffefee40,
nargout=0) at /home/jwe/src/octave/src/ov.cc:734
#25 0x00002aaaab0e076f in tree_index_expression::rvalue (this=0x16276e0, nargout=0)
at /home/jwe/src/octave/src/pt-idx.cc:352
#26 0x00002aaaab0f93b4 in tree_statement::eval (this=0x162a810, silent=<value optimized out>, nargout=0,
in_function_body=false) at /home/jwe/src/octave/src/pt-stmt.cc:133
#27 0x00002aaaab0f9834 in tree_statement_list::eval (this=0x1624a90, silent=false, nargout=0)
at /home/jwe/src/octave/src/pt-stmt.cc:190
#28 0x00002aaaaaf28a31 in main_loop () at /home/jwe/src/octave/src/toplev.cc:225
#29 0x00002aaaaaec0bc0 in octave_main (argc=3, argv=0x7fffffeff4a8, embedded=0)
at /home/jwe/src/octave/src/octave.cc:764
#30 0x00002aaaaf7c34ca in __libc_start_main () from /lib/libc.so.6
#31 0x000000000040078a in _start () at ../sysdeps/x86_64/elf/start.S:113
jwe