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.26k stars 717 forks source link

Thread tests that lead to incorrect results or blocking #19130

Open TemporaryRepos opened 5 months ago

TemporaryRepos commented 5 months ago

Affected versions

We found a test case with execution problems. To facilitate analysis, we simplified the test case and the simplified class file can ben found at attachment.

Linux Ubuntu20.04

Java -version output under Linux

openjdk version "1.8.0_402"
IBM Semeru Runtime Open Edition (build 1.8.0_402-b06)
Eclipse OpenJ9 VM (build openj9-0.43.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20240131_861 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 0fa9d9c532 based on jdk8u402-b06)
openjdk version "11.0.22" 2024-01-16
IBM Semeru Runtime Open Edition 11.0.22.0 (build 11.0.22+7)
Eclipse OpenJ9 VM 11.0.22.0 (build openj9-0.43.0, JRE 11 Linux amd64-64-Bit Compressed References 20240131_966 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 7876cac747 based on jdk-11.0.22+7)
openjdk version "17.0.10" 2024-01-16
IBM Semeru Runtime Open Edition 17.0.10.0 (build 17.0.10+7)
Eclipse OpenJ9 VM 17.0.10.0 (build openj9-0.43.0, JRE 17 Linux amd64-64-Bit Compressed References 20240116_670 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 2aad089841f based on jdk-17.0.10+7)

Problem summary

Here we have provided two test cases, in the folder bugCase, executing the test case with OpenJ9 will go to an incorrect branch and output Magic, but Hotspot will end normally. But if we remove a portion of extraneous code from test(), it causes OpenJ9 to block. We have provided two folders in the attachment, where bugCase is the test case that can output Magic and simplyCase is the test case where blocking occurs.

Steps to Reproduce

java-8/bin/java -cp ./bugCase compiler.c2.Test8004741

Expected Result

nothing

Actual Result

Magic or TimeOut

Attachment

202403131459.zip

pshipton commented 5 months ago

@hzongaro fyi

hzongaro commented 5 months ago

Playing with the simplyCase version, I was able to produce the Magic output by limiting compilation to the Test8004741.test and Test8004741.run methods. It looks like the incorrect output occurs when the run method is compiled with DLT, even at noOpt, but the test method already must have been compiled at least at warm up to opt index 28, which corresponds to Global Value Propagation.

$ java -Xjit:limit={*Test8004741.*},{*Test8004741.run*}\(optLevel=noopt,lastOptIndex=0\),{*Test8004741.test*}\(optLevel=warm,lastOptIndex=28\) -cp simplyCase compiler.c2.Test8004741
Magic
$ java -Xjit:limit={*Test8004741.*},{*Test8004741.run*}\(optLevel=noopt,lastOptIndex=0\),{*Test8004741.test*}\(optLevel=warm,lastOptIndex=27\) -cp simplyCase compiler.c2.Test8004741

@jmesyou, may I ask you to look at this problem?