Clear Context in EventLoop at construction time
We were exposing uninitialized memory and hoping our users wouldn't try
to access it. This is an overly bold assumption.
Change-Id: I286fe5e932354581419059d128563c435b16071b
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/events/simulated_event_loop.cc b/aos/events/simulated_event_loop.cc
index 83857b1..d2328fb 100644
--- a/aos/events/simulated_event_loop.cc
+++ b/aos/events/simulated_event_loop.cc
@@ -572,6 +572,7 @@
tid_(tid),
startup_tracker_(std::make_shared<StartupTracker>()),
options_(options) {
+ ClearContext();
startup_tracker_->loop = this;
scheduler_->ScheduleOnStartup([startup_tracker = startup_tracker_]() {
if (startup_tracker->loop) {
@@ -669,6 +670,7 @@
ScopedMarkRealtimeRestorer rt(runtime_realtime_priority() > 0);
SetTimerContext(monotonic_now());
on_run();
+ ClearContext();
});
}
@@ -931,6 +933,7 @@
ScopedMarkRealtimeRestorer rt(
simulated_event_loop_->runtime_realtime_priority() > 0);
DoCallCallback([monotonic_now]() { return monotonic_now; }, context);
+ simulated_event_loop_->ClearContext();
}
msgs_.pop_front();
@@ -1234,6 +1237,7 @@
ScopedMarkRealtimeRestorer rt(
simulated_event_loop_->runtime_realtime_priority() > 0);
Call([monotonic_now]() { return monotonic_now; }, monotonic_now);
+ simulated_event_loop_->ClearContext();
}
}
@@ -1283,6 +1287,7 @@
[this](monotonic_clock::time_point sleep_time) {
Schedule(sleep_time);
});
+ simulated_event_loop_->ClearContext();
}
}