On Thu, 28 May 2026 05:19:37 GMT, Tobias Hartmann <[email protected]> wrote:

>> The problem is that we are running out of metadata space and after the call 
>> to `ObjArrayKlass::klass_with_properties` in `ciObjArrayKlass::make_impl` we 
>> are not checking for OOMEs. We should check `HAS_PENDING_EXCEPTION` like we 
>> do just above. There's also a place in the LIR assembler that now needs to 
>> check if an unloaded klass is returned, similar to here:
>> 
>> https://github.com/openjdk/valhalla/blob/4c23f0ed5d6a89cd1e7ab8550b367bca296a9f30/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp#L1212-L1214
>> 
>> Thanks,
>> Tobias
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Tobias Hartmann has updated the pull request incrementally with four 
> additional commits since the last revision:
> 
>  - Fixing again ..
>  - Merge branch 'JDK-8385473' of github.com:TobiHartmann/valhalla into 
> JDK-8385473
>  - Removed unstable test
>  - Remove unstable test (again)

Okay, after running more iterations of the test in various options, it turns 
out that it's very hard to stabilize it because once the metaspace is full, 
OOMEs can be thrown from multiple places, including jtreg wrapper code:


java.lang.OutOfMemoryError: Metaspace
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3050)
        at java.base/java.lang.Class.getDeclaredMethod(Class.java:2461)
        at 
compiler.valhalla.inlinetypes.TestRefinedArrayKlassOOME.main(TestRefinedArrayKlassOOME.java:151)
        at 
java.base/java.lang.invoke.LambdaForm$DMH/0x00000000a40c1800.invokeStatic(LambdaForm$DMH)
        at 
java.base/java.lang.invoke.LambdaForm$MH/0x00000000a40c2c00.invoke(LambdaForm$MH)
        at 
java.base/java.lang.invoke.Invokers$Holder.invokeExact_MT(Invokers$Holder)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invokeImpl(DirectMethodHandleAccessor.java:155)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:583)
        at 
com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.runWith(Thread.java:1540)
        at java.base/java.lang.Thread.run(Thread.java:1527)

JavaTest Message: Test threw exception: java.lang.OutOfMemoryError: Metaspace
JavaTest Message: shutting down test

java.lang.OutOfMemoryError: Metaspace
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:974)
        at 
java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:145)
        at 
java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:776)
        at 
java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:691)
        at 
java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:620)
        at 
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:578)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:502)
        at 
com.sun.javatest.regtest.agent.MainWrapper.handleTestException(MainWrapper.java:105)
        at 
com.sun.javatest.regtest.agent.MainWrapper.access$000(MainWrapper.java:36)
        at 
com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:147)
        at java.base/java.lang.Thread.runWith(Thread.java:1540)
        at java.base/java.lang.Thread.run(Thread.java:1527)


We would need to spawn a new VM and look at the output to distinguish between 
expected OOMEs and unexpected crashes. I don't think that's worth it and 
decided to simply remove the test, especially since we have an existing test 
that intermittently triggers the failure mode already. I'll attach it to JBS 
for future reference.

-------------

PR Comment: https://git.openjdk.org/valhalla/pull/2478#issuecomment-4561043821

Reply via email to