about summary refs log tree commit diff stats
path: root/050scenario.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-19 15:07:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-19 15:45:55 -0700
commit77cdc6d03f7b5660f6df6e57a6e50b015e41e3ea (patch)
tree1cf49f61c1fb1056b7fda6a84f4f2f95bd95fbae /050scenario.cc
parentf8aa4b17efed4f56b0c023cf40eb6d6000be1748 (diff)
downloadmu-77cdc6d03f7b5660f6df6e57a6e50b015e41e3ea.tar.gz
2271 - bugfix: traces cross-contaminating errors
There were several places where we push a call on to a routine without
incrementing call-stack depth, which was used to compute the depth at
which to trace an instruction. So sometimes you ended up one depth lower
than you started a call with. Do this enough times and instructions that
should be traced at level 100 end up at level 0 and pop up as errors.

Solution: since call-stack depth is only used for tracing, include it in
the trace stream and make sure we reset it along with the trace stream.
Then catch all places where we forget to increment call-stack depth and
make sure we catch such places in the future.

When I first ran into this with Caleb I thought there must be some way
that we're writing some output into the warnings result. I didn't
recognize that the spurious output as part of the trace, just at the
wrong level.
Diffstat (limited to '050scenario.cc')
-rw-r--r--050scenario.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/050scenario.cc b/050scenario.cc
index 6dbd9f56..bf3b75e7 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -200,6 +200,11 @@ case RUN: {
   vector<recipe_ordinal> tmp_recipe = load(tmp.str());
   bind_special_scenario_names(tmp_recipe.at(0));
   transform_all();
+  if (Trace_stream) {
+    ++Trace_stream->callstack_depth;
+    trace("trace") << "run: incrementing callstack depth to " << Trace_stream->callstack_depth << end();
+    assert(Trace_stream->callstack_depth < 9000);  // 9998-101 plus cushion
+  }
   Current_routine->calls.push_front(call(tmp_recipe.at(0)));
   continue;  // not done with caller; don't increment current_step_index()
 }