From bug-octave-request at bevo dot che dot wisc dot edu Wed Jan 21 11:51:12 2004 Subject: Saving 2-dimensional cell array in MAT 5.0 format crashes octave From: "John W. Eaton" To: Quentin Spencer Cc: bug-octave at bevo dot che dot wisc dot edu Date: Wed, 21 Jan 2004 11:49:51 -0600 On 24-Dec-2003, Quentin Spencer wrote: | Bug report for Octave 2.1.52 configured for i686-pc-linux-gnu | | Description: | ----------- | | Saving cell arrays that are 2-dimensional results in octave crashing. | It appears that this does not happen with 1-dimensional cell arrays. | I am using a recent CVS version, and I save to MATLAB 5.0 file format | by default. After the crash, restarting octave and attempting to load | the file that was created also crashes octave. | | Repeat-By: | --------- | | octave:1 > a{1,1}=1; | octave:2 > a{2,1}=1; | octave:3 > save temp.mat a | octave:4 > a{2,2}=1; | octave:5 > save temp.mat a | panic: Segmentation fault -- stopping myself... | attempting to save variables to `octave-core'... | panic: attempted clean up apparently failed -- aborting... | Aborted Please try the following patch. Thanks, jwe src/ChangeLog: 2004-01-21 John W. Eaton * Cell.h (Cell::operator ()): Delete (we inherit them from Array). (maybe_resize, elem_internal): Delete unused functions. * ls-mat5.cc (write_mat5_cell_array): Cell& arg is now const. Index: src/Cell.h =================================================================== RCS file: /usr/local/cvsroot/octave/src/Cell.h,v retrieving revision 1.16 diff -u -r1.16 Cell.h --- src/Cell.h 10 Nov 2003 15:50:39 -0000 1.16 +++ src/Cell.h 21 Jan 2004 17:47:23 -0000 at @ -90,16 +90,6 @@ Cell& assign (const octave_value_list& idx, const Cell& rhs, const octave_value& fill_val = octave_value ()); - octave_value& operator () (int i) { return elem_internal (i); } - - octave_value operator () (int i) const { return elem_internal (i); } - - octave_value& operator () (int i, int j) - { return ArrayN::operator () (i, j); } - - octave_value operator () (int i, int j) const - { return ArrayN::operator () (i, j); } - // XXX FIXME XXX boolMatrix all (int dim = 0) const { return boolMatrix (); } at @ -110,28 +100,6 @@ bool is_true (void) const { return false; } static octave_value resize_fill_value (void) { return Matrix (); } - -private: - - // XXX FIXME XXX -- we need to do something intelligent if there is - // more than one dimension, but for now this is all we need... - - void maybe_resize (int n) - { - if (n >= rows ()) - resize (dim_vector (n + 1, 1), octave_value ()); - } - - octave_value& elem_internal (int n) - { - maybe_resize (n); - return elem (n); - } - - octave_value elem_internal (int n) const - { - return elem (n); - } }; #endif Index: src/ls-mat5.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/ls-mat5.cc,v retrieving revision 1.3 diff -u -r1.3 ls-mat5.cc --- src/ls-mat5.cc 16 Dec 2003 05:11:26 -0000 1.3 +++ src/ls-mat5.cc 21 Jan 2004 17:47:32 -0000 at @ -705,8 +705,8 @@ // the appropriate tag. static bool -write_mat5_cell_array (std::ostream& os, Cell& cell, bool mark_as_global, - bool save_as_floats) +write_mat5_cell_array (std::ostream& os, const Cell& cell, + bool mark_as_global, bool save_as_floats) { int nel = cell.nelem (); ------------------------------------------------------------- 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 -------------------------------------------------------------