From 396198b6bd6635fff52091131ca5be94cfab1d74 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 16 Jun 2020 12:02:45 +0100 Subject: Handle unresolved field type in compiler. Make behavior consistent with interpreter, by only resolving field types when the stored value is not null. Note that this differs from RI behavior which throws a NoClassDefFoundError when loading the BadField class. Bug: 79751666 Test: 173-missing-field-type Change-Id: I1e584f3129fd651bee1c9635c90bc30e13190a90 --- compiler/optimizing/instruction_builder.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index df236c17c1..cd68b2a7c9 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -34,6 +34,7 @@ #include "oat_file.h" #include "optimizing_compiler_stats.h" #include "quicken_info.h" +#include "reflective_handle_scope-inl.h" #include "scoped_thread_state_change-inl.h" #include "sharpening.h" #include "ssa_builder.h" @@ -1934,7 +1935,14 @@ ArtField* HInstructionBuilder::ResolveField(uint16_t field_idx, bool is_static, return nullptr; } - return resolved_field; + StackArtFieldHandleScope<1> rhs(soa.Self()); + ReflectiveHandle resolved_field_handle(rhs.NewHandle(resolved_field)); + if (resolved_field->ResolveType().IsNull()) { + // ArtField::ResolveType() may fail as evidenced with a dexing bug (b/78788577). + soa.Self()->ClearException(); + return nullptr; // Failure + } + return resolved_field_handle.Get(); } void HInstructionBuilder::BuildStaticFieldAccess(const Instruction& instruction, -- cgit v1.2.3-59-g8ed1b