ART: Correctly hard-fail method with undefined register
In case a return-object gets an undefined return value register
and an unresolved return type, the "undefined" must take precedence
and lead to a hard fail of the method.
Bug: 22045582
Change-Id: Id5595a72331cd6272aa9ebc8ff3b9cea046294a2
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 5d685da..3c808de 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -1790,9 +1790,13 @@
DCHECK(!return_type.IsUninitializedReference());
const uint32_t vregA = inst->VRegA_11x();
const RegType& reg_type = work_line_->GetRegisterType(this, vregA);
- // Disallow returning uninitialized values and verify that the reference in vAA is an
- // instance of the "return_type"
- if (reg_type.IsUninitializedTypes()) {
+ // Disallow returning undefined, conflict & uninitialized values and verify that the
+ // reference in vAA is an instance of the "return_type."
+ if (reg_type.IsUndefined()) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "returning undefined register";
+ } else if (reg_type.IsConflict()) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "returning register with conflict";
+ } else if (reg_type.IsUninitializedTypes()) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "returning uninitialized object '"
<< reg_type << "'";
} else if (!return_type.IsAssignableFrom(reg_type)) {