Mercurial > octave
changeset 24779:5f445419559f
avoid crash on exit with user-defined data types (bug #53156)
* ov-typeinfo.h, ov-typeinfo.cc (type_info::vals): Now an array
of pointers.
(type_info::register_type): Store pointer to object allocated by new
in vals array.
* Array-tc.cc: Instantiate Array<octave_value *>.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Feb 2018 14:36:25 -0500 |
parents | 06884b2a4fef |
children | 0d21e2a1cdfc |
files | libinterp/octave-value/ov-typeinfo.cc libinterp/octave-value/ov-typeinfo.h libinterp/template-inst/Array-tc.cc |
diffstat | 3 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-typeinfo.cc Mon Feb 19 11:37:36 2018 -0800 +++ b/libinterp/octave-value/ov-typeinfo.cc Tue Feb 20 14:36:25 2018 -0500 @@ -113,7 +113,7 @@ types.resize (dim_vector (len, 1), ""); - vals.resize (dim_vector (len, 1), octave_value ()); + vals.resize (dim_vector (len, 1), nullptr); unary_ops.resize (dim_vector (octave_value::num_unary_ops, len), nullptr); @@ -143,7 +143,13 @@ types (i) = t_name; - vals (i) = val; + // Yes, this object is intentionally not deleted in the destructor + // so that we avoid a crash on exit for user-defined data types. + // See bug #53156. If that problem is properly fixed, then this + // could be stored as an object instead of a pointer to an object + // allocated with new. + + vals(i) = new octave_value (val); num_types++; @@ -475,7 +481,7 @@ { if (nm == types(i)) { - retval = vals(i); + retval = *vals(i); retval.make_unique (); break; }
--- a/libinterp/octave-value/ov-typeinfo.h Mon Feb 19 11:37:36 2018 -0800 +++ b/libinterp/octave-value/ov-typeinfo.h Tue Feb 20 14:36:25 2018 -0500 @@ -236,7 +236,7 @@ Array<std::string> types; - Array<octave_value> vals; + Array<octave_value *> vals; Array<void *> unary_class_ops;
--- a/libinterp/template-inst/Array-tc.cc Mon Feb 19 11:37:36 2018 -0800 +++ b/libinterp/template-inst/Array-tc.cc Tue Feb 20 14:36:25 2018 -0500 @@ -50,5 +50,8 @@ NO_INSTANTIATE_ARRAY_SORT (octave_value); INSTANTIATE_ARRAY (octave_value, OCTINTERP_API); +NO_INSTANTIATE_ARRAY_SORT (octave_value *); +INSTANTIATE_ARRAY (octave_value *, OCTINTERP_API); + NO_INSTANTIATE_ARRAY_SORT (cdef_object); INSTANTIATE_ARRAY (cdef_object, OCTINTERP_API);