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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • None
    • repo-panama
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: