[MTE] warn about async crashes being imprecise

Bug: 175335730
Change-Id: If666c98b53dee1c63c48887f4448bc54f78a0a9f
diff --git a/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp b/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp
index 28154a7..3ff82bc 100644
--- a/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp
+++ b/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp
@@ -316,6 +316,7 @@
         StringPrintf(" from pid %d, uid %d", signal_info.sender_pid(), signal_info.sender_uid());
   }
 
+  bool is_async_mte_crash = false;
   if (!tombstone.has_signal_info()) {
     CBL("signal information missing");
   } else {
@@ -329,6 +330,9 @@
     CBL("signal %d (%s), code %d (%s%s), fault addr %s", signal_info.number(),
         signal_info.name().c_str(), signal_info.code(), signal_info.code_name().c_str(),
         sender_desc.c_str(), fault_addr_desc.c_str());
+#ifdef SEGV_MTEAERR
+    is_async_mte_crash = signal_info.number() == SIGSEGV && signal_info.code() == SEGV_MTEAERR;
+#endif
   }
 
   if (tombstone.causes_size() == 1) {
@@ -340,6 +344,11 @@
   }
 
   print_thread_registers(callback, tombstone, thread, true);
+  if (is_async_mte_crash) {
+    CBL("Note: This crash is a delayed async MTE crash. Memory corruption has occurred");
+    CBL("      in this process. The stack trace below is the first system call or context");
+    CBL("      switch that was executed after the memory corruption happened.");
+  }
   print_thread_backtrace(callback, tombstone, thread, true);
 
   if (tombstone.causes_size() > 1) {