eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 721 forks source link

Segmentation error when using Mockito and Byte-buddy-agent with Java 21 #18781

Closed jkuipers closed 9 months ago

jkuipers commented 9 months ago

Java -version output

openjdk version "21.0.1" 2023-10-17 LTS IBM Semeru Runtime Open Edition 21.0.1.0 (build 21.0.1+12-LTS) Eclipse OpenJ9 VM 21.0.1.0 (build openj9-0.42.0, JRE 21 Windows 11 amd64-64-Bit Compressed References 20231017_78 (JIT enabled, AOT enabled) OpenJ9 - 874af12ee OMR - 11700e64f JCL - cb91cd755e3 based on jdk-21.0.1+12)

Note that the problem can also be reproduced on Ubuntu, you don't need to run this on Windows.

Summary of problem

When using Mockito to mock a class, the JVM crashes with a Segmentation error. This is related to Mockito's use of the ByteBuddy java agent. When you mock an interface, which doesn't require ByteBuddy, the problem does not occur.

Diagnostic files

Even though I have these files, the problem is trivial to reproduce so I'm rather attaching a demo to do that. segmentationerror.zip

Run the sample with Maven like this: mvn compile exec:java -Dexec.mainClass=SegmentationErrorDemo

pshipton commented 9 months ago

I suspect this is a dup of https://github.com/eclipse-openj9/openj9/issues/18750, which has already been fixed for the next release.

Does it work with one of these pre-release builds for the next release?

https://openj9-artifactory.osuosl.org/artifactory/ci-openj9/Build_JDK21_x86-64_windows_Release/13/OpenJ9-JDK21-x86-64_windows-20240118-124906.tar.gz

https://openj9-artifactory.osuosl.org/artifactory/ci-openj9/Build_JDK21_x86-64_linux_Release/12/OpenJ9-JDK21-x86-64_linux-20240118-114213.tar.gz

jkuipers commented 9 months ago

Thanks for the fast response! Sorry for missing that issue, looks like I only searched in the open issues before filing this one. I just downloaded the pre-release build and can confirm that it fixes the problem. Great to see that this will be in the next release, really looking forward to adopting the OpenJ9 Java 21 implementation!

pshipton commented 9 months ago

Actually I'll keep this open for a while to make it easier for others to find.

bmarwell commented 9 months ago

Thanks, can confirm the fix works for me, too.

pshipton commented 9 months ago

Semeru 21.0.2 is published so I'll close this now.