Add missing nullptr check in LogReader::State constructor
This change only affects the code which uses replay filters.
We ran into the path where construction of State happens with no
timestamp_mapper while running log_replayer on single node logs.
The timestamp_mapper does not exist when there are no communications
with other nodes as no filters are needed for logfile sorting. This has been
reproduced by creating a unit test with a single node which has been blocked
of any communication with other nodes and by calling Register on the logged files.
Change-Id: Ie3e2f1742e0480339f572e474f5cb49a4f051525
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_reader.cc b/aos/events/logging/log_reader.cc
index 36c8e8a..fa5e5d5 100644
--- a/aos/events/logging/log_reader.cc
+++ b/aos/events/logging/log_reader.cc
@@ -1333,7 +1333,8 @@
RemapConflict conflict_handling) {
if (replay_channels_ != nullptr) {
CHECK(std::find(replay_channels_->begin(), replay_channels_->end(),
- std::make_pair(std::string{name}, std::string{type})) != replay_channels_->end())
+ std::make_pair(std::string{name}, std::string{type})) !=
+ replay_channels_->end())
<< "Attempted to remap channel " << name << " " << type
<< " which is not included in the replay channels passed to LogReader.";
}
@@ -1755,7 +1756,10 @@
multinode_filters_(multinode_filters),
threading_(threading),
replay_channel_indices_(std::move(replay_channel_indices)) {
- if (replay_channel_indices_ != nullptr) {
+ // If timestamp_mapper_ is nullptr, then there are no log parts associated
+ // with this node. If there are no log parts for the node, there will be no
+ // log data, and so we do not need to worry about the replay channel filters.
+ if (replay_channel_indices_ != nullptr && timestamp_mapper_ != nullptr) {
timestamp_mapper_->set_replay_channels_callback(
[filter = replay_channel_indices_.get()](
const TimestampedMessage &message) -> bool {