Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8322702

[Crash] Frame: jdk.internal.ref.PhantomCleanable.insert()V+7 java.base@11.0.20

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1 P1
    • None
    • 11.0.20.0.4-oracle, 11.0.21
    • hotspot
    • gc
    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      OS: Ubuntu 18.04
      Java: jdk11.0.20
      >java version "11.0.20" 2023-07-18 LTS
      >Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256)
      >Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      The G1GC crashes occurred when specific options were configured, particularly in relation to WeakReference and PhantomReference. I have narrowed down and simplified both the reproducible program and the set of options.

      The program experiences a crash with the following options: `-XX:+UseG1GC -XX:NewRatio=10000 -XX:G1UpdateBufferSize=408021884 -Xmx4096m`. In this program, arrays and WeakReference and PhantomReference are created by looping. So this crash is linked to the program's memory allocation and object reference relationships.

      It's worth noting that in this program, I've designed a custom class called `GCObj` to test the four reference relationships. Interestingly, if you substitute their instance objects with arrays of equal sizes, the program does not encounter any crashes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Step1. Download Case16.java and JDK11.0.20
      Step2. Compile and run Case16
      command:
      > ./jdk-11.0.20/bin/java -XX:+UseG1GC -XX:NewRatio=10000 -XX:G1UpdateBufferSize=408021884 -Xmx4096m Case16

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      <no output>
      ACTUAL -
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # SIGSEGV (0xb) at pc=0x00007f1b618ab5e6, pid=4731, tid=4732
      #
      # JRE version: Java(TM) SE Runtime Environment 18.9 (11.0.20+9) (build 11.0.20+9-LTS-256)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM 18.9 (11.0.20+9-LTS-256, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
      # Problematic frame:
      # j jdk.internal.ref.PhantomCleanable.insert()V+7 java.base@11.0.20
      #
      # Core dump will be written. Default location: /home/zhengkai/GC/GCFuzz/core.4731
      #
      # An error report file with more information is saved as:
      # /home/zhengkai/GC/GCFuzz/hs_err_pid4731.log
      Compiled method (c2) 160 22 4 java.lang.Object::<init> (1 bytes)
       total in heap [0x00007f1b69472910,0x00007f1b69472b30] = 544
       relocation [0x00007f1b69472a78,0x00007f1b69472a88] = 16
       main code [0x00007f1b69472aa0,0x00007f1b69472ae0] = 64
       stub code [0x00007f1b69472ae0,0x00007f1b69472af8] = 24
       metadata [0x00007f1b69472af8,0x00007f1b69472b00] = 8
       scopes data [0x00007f1b69472b00,0x00007f1b69472b08] = 8
       scopes pcs [0x00007f1b69472b08,0x00007f1b69472b28] = 32
       dependencies [0x00007f1b69472b28,0x00007f1b69472b30] = 8
      Could not load hsdis-amd64.so; library not loadable; PrintAssembly is disabled
      #
      # If you would like to submit a bug report, please visit:
      # https://bugreport.java.com/bugreport/crash.jsp
      #

      ---------- BEGIN SOURCE ----------
      import java.lang.ref.PhantomReference;
      import java.lang.ref.ReferenceQueue;
      import java.lang.ref.SoftReference;
      import java.lang.ref.WeakReference;

      // -XX:+UseG1GC -XX:NewRatio=10000 -XX:G1UpdateBufferSize=408021884 -Xmx4096m
      public class Case16 {
          static class GCObj {
              public GCObj strongReference = null;
              public SoftReference<GCObj> softReference = null;
              public WeakReference<GCObj> weakReference = null;
              public PhantomReference<GCObj> phantomReference = null;
              public byte[] space = null;

              public GCObj(GCObj strongReference, GCObj softReference, GCObj weakReference, GCObj phantomReference, int size) {
                  this.strongReference = strongReference;
                  this.softReference = new SoftReference<>(softReference);
                  this.weakReference = new WeakReference<>(weakReference);
                  ReferenceQueue<GCObj> referenceQueue = new ReferenceQueue<>();
                  this.phantomReference = new PhantomReference<>(phantomReference, referenceQueue);
                  this.space = new byte[size];
              }
          }

          public static void main(String[] var0) {
              for (int i = 0; i < 10; ++i) {
                  Object[][][] array = new Object[64][256][32];
                  GCObj root = new GCObj(null, null, null, null, 131);
                  GCObj l1 = new GCObj(null, null, root, null, 4096);
                  new GCObj(null, null, null, l1, 128);
              }
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: