-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
23
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
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
- duplicates
-
JDK-8323552 AbstractMemorySegmentImpl#mismatch returns -1 when comparing distinct areas of the same instance of MemorySegment
- Closed
- relates to
-
JDK-8323552 AbstractMemorySegmentImpl#mismatch returns -1 when comparing distinct areas of the same instance of MemorySegment
- Closed