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

Cloned object's fields observed as null after C2 escape analysis

    Details

    • Subcomponent:
    • Introduced In Build:
      b66
    • Resolved In Build:
      b81
    • CPU:
      x86
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        Testing observed a NPE in java.time.ZoneId.systemDefault() after C2 compilation.

        import java.io.IOException;
        import java.time.ZoneId;
        import java.util.TimeZone;

        public class CloneBug {

            static final TimeZone UTC = TimeZone.getTimeZone("UTC");

            static void test() {
                TimeZone.setDefault(UTC);
                for (int i = 0; i < 16801; i++) {
                    ZoneId.systemDefault();
                }
            }

            public static void main(String[] args) throws IOException {
                for (int i = 0; i < 100; i++) {
                    test();
                }
            }
        }

        Expected output: Nothing
        Actual output:
        Exception in thread "main" java.lang.NullPointerException
        at java.util.TimeZone.toZoneId0(TimeZone.java:560)
        at java.util.TimeZone.toZoneId(TimeZone.java:550)
        at java.time.ZoneId.systemDefault(ZoneId.java:274)
        at CloneBug.test(CloneBug.java:13)
        at CloneBug.main(CloneBug.java:19)

        Supplying any of the following avoids the issue:
        -Xint
        -XX:-DoEscapeAnalysis
        -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_clone
        -XX:TieredStopAtLevel=1

        Issue still reproduce using:
        -XX:-TieredCompilation

        Issue narrowed down to 9-b66, still exists in 9-b71

        ILW = Unavoidable exceptions in compiled code (H), heavy use of publicly available method used internally in the JDK will trigger (H), disabling escape analysis avoids issue entirely (L) = HHL = P2

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  roland Roland Westrelin
                  Reporter:
                  redestad Claes Redestad
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: