RFR: 8319932: [JVMCI] class unloading related tests can fail on libgraal
Doug Simon
dnsimon at openjdk.org
Wed Feb 28 14:51:04 UTC 2024
This PR addresses a race in `runtime/ClassInitErrors/InitExceptionUnloadTest.java` that is exposed by libgraal which sets the [default value for `TypeProfileWidth` to 8](https://github.com/openjdk/jdk/blob/eb4b6fa6212380c9b6d3c94f5aa3384f12a0c125/src/hotspot/share/compiler/compilerDefinitions.cpp#L429).
The problem is as follows:
* The type `InitExceptionUnloadTest$SpecialException` is loaded by a [custom class loader](https://github.com/openjdk/jdk/blob/eb4b6fa6212380c9b6d3c94f5aa3384f12a0c125/test/hotspot/jtreg/runtime/ClassInitErrors/InitExceptionUnloadTest.java#L106) and appears in the profile of `String.valueOf` as shown by `-XX:+PrintMethodData`:
static java.lang.String::valueOf(Ljava/lang/Object;)Ljava/lang/String;
interpreter_invocation_count: 957
invocation_counter: 957
backedge_counter: 0
decompile_count: 0
mdo size: 496 bytes
0 nofast_aload_0
1 ifnonnull 10
0 bci: 1 BranchData taken(698) displacement(56)
not taken(0)
4 fast_aldc_w "null"
7 goto 14
32 bci: 7 JumpData taken(0) displacement(168)
10 nofast_aload_0
11 invokevirtual 1023 <java/lang/Object.toString()Ljava/lang/String;>
56 bci: 11 VirtualCallData count(2) entries(8)
'java/lang/String'(470 0.67)
'java/lang/StackTraceElement'(204 0.29)
'java/lang/Error'(1 0.00)
'java/lang/NoClassDefFoundError'(6 0.01)
'java/lang/ExceptionInInitializerError'(8 0.01)
'InitExceptionUnloadTest$SpecialException'(2 0.00) <===== unloadable type in profile
'java/lang/OutOfMemoryError'(2 0.00)
* Types in profiles are cleaned by parallel GC worker threads when ZGC or G1 is in use. This is shown by this native stack trace:
Current thread (0x000000013ee0a660): WorkerThread "GC Thread#0" [id=13315, stack(0x000000016bb8c000,0x000000016bd8f000) (2060K)]
Stack: [0x000000016bb8c000,0x000000016bd8f000], sp=0x000000016bd8eb80, free space=2058k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.dylib+0x7d8680] ReceiverTypeData::clean_weak_klass_links(bool)+0x170
V [libjvm.dylib+0x7dc428] MethodData::clean_method_data(bool)+0x7c
V [libjvm.dylib+0x4905d0] InstanceKlass::clean_weak_instanceklass_links()+0x54
V [libjvm.dylib+0x84a6c0] KlassCleaningTask::work()+0x84
V [libjvm.dylib+0xa434ec] WorkerThread::run()+0x94
V [libjvm.dylib+0x98ab34] Thread::call_run()+0xc8
V [libjvm.dylib+0x831084] thread_native_entry(Thread*)+0x118
C [libsystem_pthread.dylib+0x7034] _pthread_start+0x88
The test currently triggers class unloading via a [whitebox full GC](https://github.com/openjdk/jdk/blob/eb4b6fa6212380c9b6d3c94f5aa3384f12a0c125/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java#L67) and then immediately expects the classes to be unloaded. Depending on how far the parallel cleaner threads have progressed, the classes may not yet be unloaded.
This PR modifies the test to add a retry loop around the unloading trigger and the check for unloaded classes.
-------------
Commit messages:
- allow more time for class unloading in InitExceptionUnloadTest
Changes: https://git.openjdk.org/jdk/pull/18044/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18044&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8319932
Stats: 21 lines in 1 file changed: 18 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/18044.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18044/head:pull/18044
PR: https://git.openjdk.org/jdk/pull/18044
More information about the hotspot-runtime-dev
mailing list