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

Crash passing null to a VarHandle

XMLWordPrintable

        Some VarHandles expect an Object argument and should throw NullPointerException if null is passed instead. But here's a program that crashes both jdk9 and jdk head:

        import static java.lang.invoke.MethodHandles.byteBufferViewVarHandle;
        import java.lang.invoke.VarHandle;
        import static java.nio.ByteOrder.LITTLE_ENDIAN;

        public class Main {
            private static final VarHandle vh
                = byteBufferViewVarHandle(int[].class, LITTLE_ENDIAN);

            public static void main(String[] args) {
                try {
                    vh.get(null, 3);
                    System.out.println("Not reached");
                } catch (NullPointerException success) {}
            }
        }

        ==> java -esa -ea Main
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # SIGSEGV (0xb) at pc=0x00007f6d101f0fdc, pid=102300, tid=102301
        #
        # JRE version: OpenJDK Runtime Environment (10.0) (build 10-internal+0-adhoc.martinrb.jdk)
        # Java VM: OpenJDK 64-Bit Server VM (10-internal+0-adhoc.martinrb.jdk, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
        # Problematic frame:
        # V [libjvm.so+0x781fdc] AccessInternal::PostRuntimeDispatch<G1SATBCardTableLoggingModRefBS::AccessBarrier<401462ul, G1SATBCardTableLoggingModRefBS>, (AccessInternal::BarrierType)3, 401462ul>::oop_access_barrier(oopDesc*, long)+0xc

              psandoz Paul Sandoz
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: