More cleanly handle potential segfault in log reading

This doesn't actually _solve_ the relevant issue, but it does prevent us
from performing invalid memory accesses in the solver, and makes it so
that we can use the non-fatal log reading checks if we want to.

Change-Id: I944c0f76a4d2bcda5720ce5d951b29702912f8f5
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/network/multinode_timestamp_filter.cc b/aos/network/multinode_timestamp_filter.cc
index a2e251d..ddb7864 100644
--- a/aos/network/multinode_timestamp_filter.cc
+++ b/aos/network/multinode_timestamp_filter.cc
@@ -750,6 +750,10 @@
   const Eigen::Ref<const Eigen::VectorXd> lambda =
       y.block(x.rows(), 0, derivatives.f.rows(), 1);
 
+  CHECK_LT(0, lambda.rows())
+      << ": You are calling the unconstrained Newton solver without inequality "
+         "constraints. This is not supported.";
+
   const Eigen::Ref<const Eigen::VectorXd> v =
       y.block(x.rows() + lambda.rows(), 0, derivatives.A.rows(), 1);
 
@@ -1086,6 +1090,13 @@
 
     PrintDerivatives(derivatives, y, "", 1);
 
+    if (derivatives.f.rows() == 0) {
+      LOG(ERROR) << "No inequality constraints provided in constrained solver. "
+                    "This suggests an inconsistency in the solver code, please "
+                    "investigate.";
+      return std::nullopt;
+    }
+
     // Figure out our descent direction.
     Eigen::VectorXd dy;
     Eigen::VectorXd rt_orig;