check for errors when deserializing types from log files

Change-Id: Ib9576110d3de938bfbaaa0bc906b7e6071cc1c62
diff --git a/aos/linux_code/logging/binary_log_file.h b/aos/linux_code/logging/binary_log_file.h
index ea4651b..efbffcf 100644
--- a/aos/linux_code/logging/binary_log_file.h
+++ b/aos/linux_code/logging/binary_log_file.h
@@ -96,6 +96,10 @@
 
   bool IsLastPage();
 
+  size_t file_offset(const void *msg) {
+    return offset() + (static_cast<const char *>(msg) - current());
+  }
+
  protected:
   // The size of the chunks that get mmaped/munmapped together. Large enough so
   // that not too much space is wasted and it's hopefully bigger than and a
diff --git a/aos/linux_code/logging/log_displayer.cc b/aos/linux_code/logging/log_displayer.cc
index 05a12fe..440235d 100644
--- a/aos/linux_code/logging/log_displayer.cc
+++ b/aos/linux_code/logging/log_displayer.cc
@@ -250,7 +250,13 @@
       size_t bytes = msg->message_size;
       ::aos::MessageType *type = ::aos::MessageType::Deserialize(
           reinterpret_cast<const char *>(msg + 1), &bytes);
-      ::aos::type_cache::Add(*type);
+      if (type == nullptr) {
+        LOG(WARNING, "Error deserializing MessageType of size %" PRIx32
+                     " starting at %zx.\n",
+            msg->message_size, reader.file_offset(msg + 1));
+      } else {
+        ::aos::type_cache::Add(*type);
+      }
       continue;
     }