Fix recursive initialization on app image.
Assume class B extends class A and class A's clinit tries to instantiate
class B as a field. In this case, class A is under initializing but
ClassLinker allows initialize B as class A is initialized. If class B is
initialized successfully and transaction is commited then class A abort
the transaction, status of class B will not be reverted.
Fixed by a simple approach, when compiling images, AotClassLinker does
not allow initialize a subclass when it's superclass is not fully
initialized.
A testcase produce this error is added in /c/433381
Test: make test-art-host -j64
Change-Id: Ic6bcbf1a5162d0e6ec26979b336c0f644a1c39bc
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 1219f6f..fae18ac 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4895,7 +4895,9 @@
if (!super_initialized) {
// The super class was verified ahead of entering initializing, we should only be here if
// the super class became erroneous due to initialization.
- CHECK(handle_scope_super->IsErroneous() && self->IsExceptionPending())
+ // For the case of aot compiler, the super class might also be initializing but we don't
+ // want to process circular dependencies in pre-compile.
+ CHECK(self->IsExceptionPending())
<< "Super class initialization failed for "
<< handle_scope_super->PrettyDescriptor()
<< " that has unexpected status " << handle_scope_super->GetStatus()