changeset 29064:336356206de7 stable

don't clear stack frame values indirectly through call stack (bug #59432) * pt-eval.cc (tree_evaluator::execute_user_function): Save reference to current stack frame in unwind_action instead of using call_stack::clear_current_frame_values. * call-stack.h, call-stack.cc (call_stack::clear_current_frame_values): Delete unused function. * stack-frame.cc (stack_frame::clear_values): Issue warning instead of calling panic_impossible.
author John W. Eaton <jwe@octave.org>
date Fri, 13 Nov 2020 20:38:28 -0500
parents 9d42195f42e9
children be19672a3c49 a922c2176394
files libinterp/corefcn/call-stack.cc libinterp/corefcn/call-stack.h libinterp/corefcn/stack-frame.cc libinterp/parse-tree/pt-eval.cc
diffstat 4 files changed, 8 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc	Fri Nov 13 16:24:56 2020 -0500
+++ b/libinterp/corefcn/call-stack.cc	Fri Nov 13 20:38:28 2020 -0500
@@ -1104,11 +1104,6 @@
     return octave_value ();
   }
 
-  void call_stack::clear_current_frame_values (void)
-  {
-    m_cs[m_curr_frame]->clear_values ();
-  }
-
   void call_stack::display (void) const
   {
     std::ostream& os = octave_stdout;
--- a/libinterp/corefcn/call-stack.h	Fri Nov 13 16:24:56 2020 -0500
+++ b/libinterp/corefcn/call-stack.h	Fri Nov 13 20:38:28 2020 -0500
@@ -293,8 +293,6 @@
                                     bool have_regexp, bool return_list,
                                     bool verbose, const std::string& msg = "");
 
-    void clear_current_frame_values (void);
-
     void display (void) const;
 
     void set_auto_fcn_var (stack_frame::auto_var_type avt,
--- a/libinterp/corefcn/stack-frame.cc	Fri Nov 13 16:24:56 2020 -0500
+++ b/libinterp/corefcn/stack-frame.cc	Fri Nov 13 20:38:28 2020 -0500
@@ -1074,14 +1074,13 @@
     return new scope_stack_frame (tw, scope, index, parent_link, static_link);
   }
 
-  // This function is only implemented for user_fcn stack frames and
-  // only called for those objects using unwind_protect and the
-  // call_stack::clear_current_frame_values function.  Anything else
-  // indicates an error in the implementation.
+  // This function is only implemented and should only be called for
+  // user_fcn stack frames.  Anything else indicates an error in the
+  // implementation, but we'll simply warn if that happens.
 
   void stack_frame::clear_values (void)
   {
-    panic_impossible ();
+    warning ("invalid call to stack_frame::clear_values; please report");
   }
 
   symbol_info_list
--- a/libinterp/parse-tree/pt-eval.cc	Fri Nov 13 16:24:56 2020 -0500
+++ b/libinterp/parse-tree/pt-eval.cc	Fri Nov 13 20:38:28 2020 -0500
@@ -2740,9 +2740,10 @@
 
     unwind_protect_var<stmt_list_type> upv (m_statement_context, SC_FUNCTION);
 
-    unwind_action act1 ([this] () {
-                          m_call_stack.clear_current_frame_values ();
-                        });
+    unwind_action act1 ([] (std::shared_ptr<stack_frame> frame)
+                       {
+                         frame->clear_values ();
+                       }, m_call_stack.get_current_stack_frame ());
 
     {
       profiler::enter<octave_user_function> block (m_profiler, user_function);