From e93505f599682a2e95c4dac1c8633dec79c602bc Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 31 Jul 2015 11:34:24 -0700 Subject: [PATCH] ART: Do not allow RETURN_VOID_NO_BARRIER outside constructors Let the verifier fail non-constructor methods using the no-barrier variant of return. This is a quickened return purely to avoid the constructor barrier for final fields, and cannot be used as a stand-in for a regular return. Bug: https://code.google.com/p/android/issues/detail?id=181700 Bug: 22871329 Change-Id: I9559c6a1599c20ce526582527ebed73b25242767 --- runtime/verifier/method_verifier.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index d63b45566..021102e47 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -2873,6 +2873,10 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { break; } } + } else { + Fail(VERIFY_ERROR_BAD_CLASS_HARD) + << "return-void-no-barrier not expected for non-constructor method " + << PrettyMethod(dex_method_idx_, *dex_file_, true); } break; // Note: the following instructions encode offsets derived from class linking. -- 2.11.0