RFR: 8319932: [JVMCI] class unloading related tests can fail on libgraal [v2]
David Holmes
dholmes at openjdk.org
Mon Mar 4 02:48:43 UTC 2024
On Fri, 1 Mar 2024 12:38:06 GMT, Doug Simon <dnsimon at openjdk.org> wrote:
>> 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 that `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)
>>
>>
>> When this method is being compiled at tier 3, C1 makes a strong GC root for each type in the profile. Only once the compilation completes, are these strong roots released.
>>
>> 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. If the above C1 compilation is still in progress, 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.
>
> Doug Simon has updated the pull request incrementally with one additional commit since the last revision:
>
> move retry loop for class unloading to lib code
Thanks for fixing it this way. Some minor javadoc suggestions but otherwise this looks good.
test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java line 74:
> 72:
> 73: /**
> 74: * Calls triggerUnloading() in a retry loop for 2 seconds until WhiteBox.isClassAlive
s/until/or until/
Also please add
@param classNames the set of classes that are expected to be unloaded
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/18044#pullrequestreview-1913287051
PR Review Comment: https://git.openjdk.org/jdk/pull/18044#discussion_r1510528789
More information about the hotspot-runtime-dev
mailing list