From 0ca4b45a0ccf9e29a17f0613fb280411910b3dbd Mon Sep 17 00:00:00 2001 From: Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> Date: Mon, 19 Feb 2018 12:00:15 +0100 Subject: [PATCH] Step limit is now terminator limit --- src/librustc/mir/interpret/error.rs | 2 +- src/librustc_mir/interpret/eval_context.rs | 2 +- src/librustc_mir/interpret/step.rs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index bb27628fa9c..d6df340e2f6 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -196,7 +196,7 @@ impl<'tcx> Error for EvalError<'tcx> { OutOfMemory{..} => "could not allocate more memory", ExecutionTimeLimitReached => - "reached the configured maximum execution time", + "the expression was too complex to be evaluated or resulted in an infinite loop", StackFrameLimitReached => "reached the configured maximum number of stack frames", OutOfTls => diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index f46d5631060..64e82356467 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -41,7 +41,7 @@ pub struct EvalContext<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { /// The maximum number of stack frames allowed pub(crate) stack_limit: usize, - /// The maximum number of operations that may be executed. + /// The maximum number of terminators that may be evaluated. /// This prevents infinite loops and huge computations from freezing up const eval. /// Remove once halting problem is solved. pub(crate) steps_remaining: usize, diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs index 54fd364d3f8..4e1750caf26 100644 --- a/src/librustc_mir/interpret/step.rs +++ b/src/librustc_mir/interpret/step.rs @@ -19,7 +19,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { /// Returns true as long as there are more things to do. pub fn step(&mut self) -> EvalResult<'tcx, bool> { - self.inc_step_counter_and_check_limit(1)?; if self.stack.is_empty() { return Ok(false); } @@ -37,6 +36,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { return Ok(true); } + self.inc_step_counter_and_check_limit(1)?; + let terminator = basic_block.terminator(); assert_eq!(old_frames, self.cur_frame()); self.terminator(terminator)?;