From c7cc571fa186f5eceb7f52726a156c348b33866e Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Fri, 17 Nov 2023 22:12:14 +0000 Subject: [PATCH] Avoid crashing on bad architecture value. The only way to get a bad architecture value in the protobuf is if the data was corrupted or an unsupported architecture was added without the register support. If the protobuf is corrupted, this is strictly better since it still produces a tombstone with the data present. If there is an unsupported architecture, it will still result in a tombstone, only the registers would not be present. It would also be very obviously a problem that needs to be fixed. Again, this is strictly better since the crash in generation is not necessarily visible unless you look at the log. Here, the data is in the log and in the tombstone. This also removes the only dependency in this file on the async_safe library. Test: Ran unit tests. Test: Forced an invalid architecture and verified tombstone is present Test: with error message, and error message printed in the log. Change-Id: I8e4a2e3f778fafb5b7241c2f23d5f867f1341ed8 --- debuggerd/libdebuggerd/tombstone_proto_to_text.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp b/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp index eed81fc15..e44dc1095 100644 --- a/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp +++ b/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "tombstone.pb.h" @@ -138,7 +137,8 @@ static void print_thread_registers(CallbackType callback, const Tombstone& tombs break; default: - async_safe_fatal("unknown architecture"); + CBL("Unknown architecture %d printing thread registers", tombstone.arch()); + return; } for (const auto& reg : thread.registers()) {