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

Incorrect result for MemorySegment::mismatch when comparing different sections of the same segment

XMLWordPrintable

      The implementation of MemorySegment::mismatch has a fast path for cases where a memory segment is being compared to itself:

      if (dstImpl == srcImpl) {
          srcImpl.checkValidState();
          return -1;
      }

      However, the same memory segment can be compared against itself at different offsets (using the static version of mismatch), in which case the compared sections are not guaranteed to be equal to each other.

      This is likely a leftover from when we only had the instance mismatch method, which doesn't accept any offsets.

      The attached test case demonstrates the issue. Reported on the mailing list: https://mail.openjdk.org/pipermail/panama-dev/2024-January/020208.html

            pminborg Per-Ake Minborg
            jvernee Jorn Vernee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: