From bug-request at octave dot org Sat Jul 24 07:35:09 2004 Subject: Re: cell index crashes 2.1.57 From: David Bateman To: bugs at octave dot org Date: Sat, 24 Jul 2004 14:34:17 +0200 --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Confirmed with the CVS under linux octave:1> v1= {1,2}; octave:2> s1(1,2)=1; octave:3> s2(1,2).b=1; octave:4> s1( v1 ) error: cell type invalid as index value octave:4> s2( v1 ) error: cell type invalid as index value octave: ../liboctave/dim-vector.h:104: int& dim_vector::dim_vector_rep::elem(int): Assertion `i >= 0 && i < ndims' failed. panic: Aborted -- stopping myself... attempting to save variables to `octave-core'... save to `octave-core' complete Abort If I remember correctly, even s1(v1) would have failed in this manner prior to 2004-04-08 John W. Eaton * ov-base-mat.cc (octave_base_matrix::do_index_op): Quit early if an error occurs when creating index vector object. Though that is after 2.1.57. In seems that src/Cell.cc needs similar treatment. Try the patch below. I have some other stuff in my tree, so although this should patch cleanly, it might have a little fuzz. After applying this patch I get octave:1> v1={1,2}; octave:2> s2(1,2).b = 1; octave:3> s2(v1) error: cell type invalid as index value octave:3> Cheers D. -- David Bateman David dot Bateman at motorola dot com Motorola CRM +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.Cell" --- src/Cell.cc.orig2 2004-07-24 14:18:21.000000000 +0200 +++ src/Cell.cc 2004-07-24 14:25:20.000000000 +0200 at @ -31,6 +31,7 @@ #include "idx-vector.h" #include "Cell.h" +#include "error.h" Cell::Cell (const string_vector& sv) : ArrayN () at @ -59,16 +60,22 @@ { idx_vector i = idx_arg(0).index_vector (); - retval = index (i, resize_ok); + if (! error_state) + retval = index (i, resize_ok); } break; case 2: { idx_vector i = idx_arg(0).index_vector (); - idx_vector j = idx_arg(1).index_vector (); - retval = index (i, j, resize_ok); + if (! error_state) + { + idx_vector j = idx_arg(1).index_vector (); + + if (! error_state) + retval = index (i, j, resize_ok); + } } break; at @ -77,9 +84,15 @@ Array iv (n); for (int i = 0; i < n; i++) - iv(i) = idx_arg(i).index_vector (); + { + iv(i) = idx_arg(i).index_vector (); - retval = index (iv, resize_ok); + if (error_state) + break; + } + + if (!error_state) + retval = index (iv, resize_ok); } break; } --ZPt4rx8FFjLCG7dd-- ------------------------------------------------------------- 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 -------------------------------------------------------------