diff libinterp/parse-tree/pt-eval.cc @ 15244:c16357c4bdbb

attempt to display location of out of memory errors in interpreted code * pt-eval.cc (tree_evaluator::visit_statement): Handle std::bad_alloc exception here. * toplev.cc (main_loop): Simplify out-of-memory error message. * octave.cc (safe_source_file): Don't handle std::bad_alloc here. (execute_eval_option_code): Likewise. * ov-oncleanup.cc (octave_oncleanup::~octave_oncleanup): Likewise.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Aug 2012 11:00:53 -0400
parents 2fc554ffbc28
children b055fc077224
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc	Tue Aug 28 09:42:48 2012 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Tue Aug 28 11:00:53 2012 -0400
@@ -757,6 +757,19 @@
         {
           gripe_library_execution_error ();
         }
+      catch (std::bad_alloc)
+        {
+          // FIXME -- We want to use error_with_id here so that we set
+          // the error state, give users control over this error
+          // message, and so that we set the error_state appropriately
+          // so we'll get stack trace info when appropriate.  But
+          // error_with_id will require some memory allocations.  Is
+          // there anything we can do to make those more likely to
+          // succeed?
+
+          error_with_id ("Octave:bad-alloc",
+                         "out of memory or dimension too large for Octave's index type");
+        }
     }
 }
 
@@ -897,7 +910,6 @@
   if (try_code)
     {
       try_code->accept (*this);
-      // FIXME: should std::bad_alloc be handled here?
     }
 
   if (error_state)