diff options
author | 2021-05-21 16:36:23 +0100 | |
---|---|---|
committer | 2021-05-24 13:03:10 +0000 | |
commit | d42902692d1fbb101a3c60ba314df69005da9c83 (patch) | |
tree | 76d495db0ab6160c1fe1b0e1f046da1260272265 | |
parent | 8f8935ce292bec925e8a18719227df9ad06a111d (diff) |
dex2oat: Abort app compilation without boot image.
Also avoid crash in GraphChecker for bad instructions that
throw into catch block but do not have an environment. And
DCHECK() that java_lang_Double_doubleToRawLongBits and
java_lang_Float_floatToRawIntBits are intrinsics.
Test: New test Dex2oatTest.MissingBootImageTest.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 188684102
Change-Id: I13ec2ee8a7968c0a5652aa67ec6291d07a986c80
-rw-r--r-- | compiler/optimizing/critical_native_abi_fixup_arm.cc | 1 | ||||
-rw-r--r-- | compiler/optimizing/graph_checker.cc | 7 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 6 | ||||
-rw-r--r-- | dex2oat/dex2oat_test.cc | 16 |
4 files changed, 29 insertions, 1 deletions
diff --git a/compiler/optimizing/critical_native_abi_fixup_arm.cc b/compiler/optimizing/critical_native_abi_fixup_arm.cc index 11d42a41ee..3c4db4bca7 100644 --- a/compiler/optimizing/critical_native_abi_fixup_arm.cc +++ b/compiler/optimizing/critical_native_abi_fixup_arm.cc @@ -49,6 +49,7 @@ static void FixUpArguments(HInvokeStaticOrDirect* invoke) { : WellKnownClasses::java_lang_Float_floatToRawIntBits; ArtMethod* resolved_method = jni::DecodeArtMethod(known_method); DCHECK(resolved_method != nullptr); + DCHECK(resolved_method->IsIntrinsic()); MethodReference target_method(nullptr, 0); { ScopedObjectAccess soa(Thread::Current()); diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index 44de54eccf..d1769cea0d 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -507,7 +507,12 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) { } } - if (instruction->CanThrowIntoCatchBlock()) { + if (instruction->CanThrow() && !instruction->HasEnvironment()) { + AddError(StringPrintf("Throwing instruction %s:%d in block %d does not have an environment.", + instruction->DebugName(), + instruction->GetId(), + current_block_->GetBlockId())); + } else if (instruction->CanThrowIntoCatchBlock()) { // Find the top-level environment. This corresponds to the environment of // the catch block since we do not inline methods with try/catch. HEnvironment* environment = instruction->GetEnvironment(); diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index e7391c57d7..38dd23ec7a 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1568,6 +1568,12 @@ class Dex2Oat final { LOG(ERROR) << "Missing required boot image(s) for boot image extension."; return dex2oat::ReturnCode::kOther; } + } else { + // Check that we loaded at least the primary boot image for app compilation. + if (runtime_->GetHeap()->GetBootImageSpaces().empty()) { + LOG(ERROR) << "Missing primary boot image for app compilation."; + return dex2oat::ReturnCode::kOther; + } } if (!compilation_reason_.empty()) { diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc index e2ad018c59..c4c39c2a5f 100644 --- a/dex2oat/dex2oat_test.cc +++ b/dex2oat/dex2oat_test.cc @@ -1419,6 +1419,22 @@ TEST_F(Dex2oatTest, UncompressedTest) { })); } +TEST_F(Dex2oatTest, MissingBootImageTest) { + std::string out_dir = GetScratchDir(); + const std::string base_oat_name = out_dir + "/base.oat"; + std::string error_msg; + int status = GenerateOdexForTestWithStatus( + { GetTestDexFileName("MainUncompressedAligned") }, + base_oat_name, + CompilerFilter::Filter::kVerify, + &error_msg, + // Note: Extra options go last and the second `--boot-image` option overrides the first. + { "--boot-image=/nonx/boot.art" }); + // Expect to fail with code 1 and not SIGSEGV or SIGABRT. + ASSERT_TRUE(WIFEXITED(status)); + ASSERT_EQ(WEXITSTATUS(status), 1) << error_msg; +} + TEST_F(Dex2oatTest, EmptyUncompressedDexTest) { std::string out_dir = GetScratchDir(); const std::string base_oat_name = out_dir + "/base.oat"; |