Handle null WellKnownClasses::java_lang_Object
May be null early during runtime creation. Fixes gcstress tests.
Bug: 37531237
Bug: 12687968
Test: test/run-test --host --gcstress --gdb 004-ThreadStress
Test: test-art-host
Change-Id: I5bee19ba102b046fdbf2ab53722b7e1b87db98b1
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index 80b569a..d5af29e 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -376,8 +376,15 @@
cc->VerifyGrayImmuneObjects();
}
}
- cc->java_lang_Object_ = down_cast<mirror::Class*>(cc->Mark(
- WellKnownClasses::ToClass(WellKnownClasses::java_lang_Object).Ptr()));
+ // May be null during runtime creation, in this case leave java_lang_Object null.
+ // This is safe since single threaded behavior should mean FillDummyObject does not
+ // happen when java_lang_Object_ is null.
+ if (WellKnownClasses::java_lang_Object != nullptr) {
+ cc->java_lang_Object_ = down_cast<mirror::Class*>(cc->Mark(
+ WellKnownClasses::ToClass(WellKnownClasses::java_lang_Object).Ptr()));
+ } else {
+ cc->java_lang_Object_ = nullptr;
+ }
}
private:
@@ -2071,6 +2078,7 @@
size_t data_offset = mirror::Array::DataOffset(component_size).SizeValue();
if (data_offset > byte_size) {
// An int array is too big. Use java.lang.Object.
+ CHECK(java_lang_Object_ != nullptr);
AssertToSpaceInvariant(nullptr, MemberOffset(0), java_lang_Object_);
CHECK_EQ(byte_size, (java_lang_Object_->GetObjectSize<kVerifyNone, kWithoutReadBarrier>()));
dummy_obj->SetClass(java_lang_Object_);