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

Use of pointer from scope.allocateArray with 0 element cause IllegalStateException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: repo-panama
    • Fix Version/s: None
    • Component/s: core-libs

      Description

      Given a native function with following prototype,

      int sum_ptr(int *ar, int len);

      Calling it from Java with

                  Array<Integer> ar = scope.allocateArray(NativeTypes.INT, 0);
                  fap.sum_ptr(ar.elementPointer(), 0);

      will cause following exception to be thrown,

      java.lang.IllegalStateException: offset: 0, region length: 0
      at java.base/jdk.internal.foreign.memory.MemoryBoundInfo.checkRange(MemoryBoundInfo.java:101)
      at java.base/jdk.internal.foreign.memory.BoundedPointer.checkRange(BoundedPointer.java:212)
      at java.base/jdk.internal.foreign.memory.BoundedPointer.checkAccess(BoundedPointer.java:232)
      at java.base/jdk.internal.foreign.memory.BoundedPointer.checkAccess(BoundedPointer.java:236)
      at java.base/jdk.internal.foreign.memory.BoundedPointer.addr(BoundedPointer.java:108)
      at java.base/jdk.internal.foreign.abi.DirectSignatureShuffler.pointerToLong(DirectSignatureShuffler.java:319)
      at test.arrayparam.funcArrayParam_h$Impl/0x00000007c0374440.sum_ptr(Unknown Source)
      at FuncArrayParamTest.testSumPtr(FuncArrayParamTest.java:82)

        Attachments

          Activity

            People

            Assignee:
            henryjen Henry Jen
            Reporter:
            henryjen Henry Jen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: