ART: Avoid obvious segfault in arm & x86 fault handler
These handlers need to read an instruction to determine where to
look for info. Don't try to read from pc=0.
Bug: 20040863
Change-Id: I38b56dc6dd806df22e608ee8d46c4091a738e4bc
diff --git a/runtime/arch/arm/fault_handler_arm.cc b/runtime/arch/arm/fault_handler_arm.cc
index 325b283..3e8b367 100644
--- a/runtime/arch/arm/fault_handler_arm.cc
+++ b/runtime/arch/arm/fault_handler_arm.cc
@@ -95,6 +95,13 @@
// Need to work out the size of the instruction that caused the exception.
uint8_t* ptr = reinterpret_cast<uint8_t*>(sc->arm_pc);
VLOG(signals) << "pc: " << std::hex << static_cast<void*>(ptr);
+
+ if (ptr == nullptr) {
+ // Somebody jumped to 0x0. Definitely not ours, and will definitely segfault below.
+ *out_method = nullptr;
+ return;
+ }
+
uint32_t instr_size = GetInstructionSize(ptr);
*out_return_pc = (sc->arm_pc + instr_size) | 1;