Merge "tp: workaround OOB offset returned by SQLite in sqlite3_error_offset" into main
diff --git a/src/trace_processor/sqlite/sql_source.cc b/src/trace_processor/sqlite/sql_source.cc
index 6650d71..19a44e9 100644
--- a/src/trace_processor/sqlite/sql_source.cc
+++ b/src/trace_processor/sqlite/sql_source.cc
@@ -132,7 +132,12 @@
 std::string SqlSource::AsTracebackForSqliteOffset(
     std::optional<uint32_t> opt_offset) const {
   uint32_t offset = opt_offset.value_or(0);
-  PERFETTO_CHECK(offset <= sql().size());
+  // It's possible for SQLite in rare cases to return an out-of-bounds
+  // offset. This has been reported upstream; for now workaround this
+  // by using zero as the offset if it's out of bounds.
+  if (offset > sql().size()) {
+    offset = 0;
+  }
   return AsTraceback(offset);
 }