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

j.l.foreign.VaList::skip call could throw java.lang.IndexOutOfBoundsException: Out of bound access on segment

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 19
    • 19
    • core-libs

        The following code or similar when run on MacOS AArch64

                VaList vaList = VaList.make(b -> b.addVarg(ValueLayout.JAVA_LONG, 1), MemorySession.openShared());
                vaList.skip(ValueLayout.JAVA_LONG);
                vaList.skip(ValueLayout.JAVA_LONG);
                vaList.skip(ValueLayout.JAVA_LONG);
                vaList.skip(ValueLayout.JAVA_LONG);
                vaList.skip(ValueLayout.JAVA_LONG);

        leads to

        Exception in thread "main" java.lang.IndexOutOfBoundsException: Out of bound access on segment MemorySegment{ id=0x3a2eb306 limit: 0 }; new offset = 8; new length = 0
        at java.base/jdk.internal.foreign.AbstractMemorySegmentImpl.outOfBoundException(AbstractMemorySegmentImpl.java:416)
        at java.base/jdk.internal.foreign.AbstractMemorySegmentImpl.checkBounds(AbstractMemorySegmentImpl.java:400)
        at java.base/jdk.internal.foreign.AbstractMemorySegmentImpl.asSlice(AbstractMemorySegmentImpl.java:115)
        at java.base/jdk.internal.foreign.AbstractMemorySegmentImpl.asSlice(AbstractMemorySegmentImpl.java:67)
        at java.base/jdk.internal.foreign.abi.aarch64.macos.MacOsAArch64VaList.skip(MacOsAArch64VaList.java:134)

        Specification could deserve clarification - for example mention of IndexOutOfBoundsException

        https://download.java.net/java/early_access/jdk19/docs/api/java.base/java/lang/foreign/VaList.html#skip(java.lang.foreign.MemoryLayout...)

              jvernee Jorn Vernee
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: