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.27k stars 721 forks source link

Unexpected NullPointerException During Execution with OpenJ9 JDK8 #18836

Open Qeryu opened 7 months ago

Qeryu commented 7 months ago

Java -version output

openjdk version "1.8.0_402-internal"  
OpenJDK Runtime Environment (build 1.8.0_402-internal_2024_01_05_11_05-b00)  
Eclipse OpenJ9 VM (build master-1b60ab828, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20240105_000000 (JIT enabled, AOT enabled)  
OpenJ9   - 1b60ab828  
OMR      - 3a4787401  
JCL      - b058bf977e based on jdk8u402-b05)

javac 1.8.0_402-internal

Summary of problem

When running the following test case with OpenJ9 JDK8, a java.lang.NullPointerException occurs. Upon observation, there is no apparent use of null-pointer in the program.

class Test {
  long a;
  void b() {
    for (int i = 0; i < 10000; ++i) {
      for (int c = 1; c < 10; c++) {
        for (int d = 2; d < 8; d += 2) ;
        long e = (long)c * c - 61;
        if (e <= 2)
          a = Long.valueOf(e + 61);
        else
          a = 0;
      }
      for (int f = 0; f < 20000; ++f) ;
    }
  }
  void g() { b(); }
  public static void main(String[] h) {
    Test i = new Test();
    i.g();
    System.out.println("finished");
  }
}

In the absence of JIT compiler, the JVM can execute the aforementioned test case normally. Moreover, it can also execute normally when JIT is forcibly enabled.

$ openj9-openjdk-jdk8/.../java Test
Exception in thread "main" java.lang.NullPointerException
    at Test.b(Test.java:9)
    at Test.g(Test.java:16)
    at Test.main(Test.java:19)

$ openj9-openjdk-jdk8/.../java -Xint Test
finished
$ openj9-openjdk-jdk8/.../java -Xjit:count=0,optLevel=veryhot Test
finished
pshipton commented 7 months ago

@hzongaro fyi

hzongaro commented 7 months ago

@Qeryu, I'm having difficult reproducing this failure. Are you able to reproduce the failure with this option added? If so, please attach to this issue any jitdump file produced.

-Xdump:jit:events=throw+systhrow,filter=java/lang/NullPointerException#Test.b
Qeryu commented 7 months ago

I am still able to consistently reproduce this issue. When I execute using the command you provided, the result is as follows:

$ openj9-openjdk-jdk8/.../java -Xdump:jit:events=throw+systhrow,filter=java/lang/NullPointerException#Test.b Test
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/NullPointerException" at 2024/01/30 12:30:10 - please wait.
JVMDUMP032I JVM requested JIT dump using '/data/user/proj/bugs/crash-bugs/Test/reduce/jitdump.20240130.123010.3034752.0001.dmp' in response to an event
JVMDUMP051I JIT dump occurred in 'main' thread 0x000000000003F300
JVMDUMP010I JIT dump written to /data/user/proj/bugs/crash-bugs/Test/reduce/jitdump.20240130.123010.3034752.0001.dmp
JVMDUMP013I Processed dump event "systhrow", detail "java/lang/NullPointerException".
JVMDUMP039I Processing dump event "throw", detail "java/lang/NullPointerException" at 2024/01/30 12:30:10 - please wait.
JVMDUMP032I JVM requested JIT dump using '/data/user/proj/bugs/crash-bugs/Test/reduce/jitdump.20240130.123010.3034752.0002.dmp' in response to an event
JVMDUMP051I JIT dump occurred in 'main' thread 0x000000000003F300
JVMDUMP010I JIT dump written to /data/user/proj/bugs/crash-bugs/Test/reduce/jitdump.20240130.123010.3034752.0002.dmp
JVMDUMP013I Processed dump event "throw", detail "java/lang/NullPointerException".
Exception in thread "main" java.lang.NullPointerException
        at Test.b(Test.java:9)
        at Test.g(Test.java:16)
        at Test.main(Test.java:19)

jitdump.20240130.123010.3034752.0001.dmp jitdump.20240130.123010.3034752.0002.dmp

Qeryu commented 7 months ago

I used the release version compiled from the latest source code obtained from the repository at ibmruntimes/openj9-openjdk-jdk8: Extensions for OpenJDK8 for Eclipse OpenJ9 (github.com).

Qeryu commented 7 months ago

I used -Xdump:java:events=systhrow+throw,filter=java/lang/NullPointerException#Test.b to obtain some dump files with more infomation, hoping that this content can help you reproduce this issue.

javacore.20240130.154539.3181121.0001.txt javacore.20240130.154539.3181121.0002.txt

hzongaro commented 7 months ago

Strangely, the jitdump files that were produced are nearly empty. May I ask you to try running with these options instead? Please attaching any core files and log files whose names begin with issue18836.log.

-Xdump:system:events=throw+systhrow,filter=java/lang/NullPointerException#Test.b '-Xjit:{Test.*}(traceFull,log=issue18836.log)'
Qeryu commented 7 months ago

Strangely, the jitdump files that were produced are nearly empty. May I ask you to try running with these options instead? Please attaching any core files and log files whose names begin with issue18836.log.

-Xdump:system:events=throw+systhrow,filter=java/lang/NullPointerException#Test.b '-Xjit:{Test.*}(traceFull,log=issue18836.log)'

here is the log file I obtained after running it, the original name of file is "issue18836.log.3214634.67207.20240131.101327.3214634":

issue18836.log.3214634.67207.20240131.101327.3214634.log

hzongaro commented 3 months ago

@Qeryu, sorry for leaving you waiting so long on this. Was any core file produced along with the log file that you posted in your last comment, from 2024-01-30? If so, and you still have that core file, may I ask you to post a gzipped copy of it here or in Box, or anywhere else you might be able to share the core file?

If you no longer have the core file, may I ask you to try running again with the following options, and attach any core files along with any log files whose names begin issue18836.20240614.log? The core file together with the log file will be very important in helping us understand what might be going wrong.

-Xdump:system:events=throw+systhrow,filter=java/lang/NullPointerException#Test.b '-Xjit:{Test.*}(traceFull,log=issue18836.20240614.log)'

I'll place this issue into the "Future" release for now, as we won't be able to get a fix into the 0.46 release.