From bug-octave-request at bevo dot che dot wisc dot edu Tue Nov 18 09:48:55 2003 Subject: coredump by illegal NDArray reference From: "John W. Eaton" To: Fabian at isas-berlin dot de Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 18 Nov 2003 09:48:52 -0600 On 18-Nov-2003, Fabian at isas-berlin dot de wrote: | octave:1> computer | i686-pc-cygwin # Win NT | | octave:2> y=rand(3,3,3); # OK | | octave:3> y(:,1) # forgotten to | # specify all 3 dims | | assertion "ndims () == 2" failed: file "Array.cc", line 1964 | panic: IOT instruction -- stopping myself... | attempting to save variables to `octave-core'... | error: invalid converstion of NDArray to Matrix | save to `octave-core' complete | Aborted (core dumped) Please try the following patch. Thanks, jwe src/ChangeLog: 2003-11-18 John W. Eaton * ov-base-mat.cc (octave_base_matrix::do_index_op): Ensure correct number of indices for Array indexing code. Index: src/ov-base-mat.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/ov-base-mat.cc,v retrieving revision 1.22 diff -u -r1.22 ov-base-mat.cc --- src/ov-base-mat.cc 13 Nov 2003 04:38:05 -0000 1.22 +++ src/ov-base-mat.cc 18 Nov 2003 15:47:19 -0000 at @ -127,10 +127,18 @@ { case 2: { - idx_vector i = idx (0).index_vector (); - idx_vector j = idx (1).index_vector (); + int nd = matrix.ndims (); - retval = MT (matrix.index (i, j, resize_ok, MT::resize_fill_value ())); + if (nd == 2) + { + idx_vector i = idx (0).index_vector (); + idx_vector j = idx (1).index_vector (); + + retval = MT (matrix.index (i, j, resize_ok, MT::resize_fill_value ())); + } + else + error ("invalid number of indices (= 2) for %d-dimensional array", + nd); } break; ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------