RFR: 8323552: AbstractMemorySegmentImpl#mismatch returns -1 when comparing distinct areas of the same instance of MemorySegment
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Jan 10 22:15:21 UTC 2024
On Wed, 10 Jan 2024 20:54:20 GMT, Peter Levart <plevart at openjdk.org> wrote:
> I belive there is a bug in `AbstractMemorySegmentImpl#mismatch` method. It returns `-1` (meaning that regions are equal) when passing the same instance of MemorySegment as both `srcSegment` and `dstSegment` parameters regardless of whether `srcFromOffset` and `dstFromOffset` as well as `srcToOffset` and `dstToOffset` are also equal.
>
> Am I right?
Note there's another bug for this: https://bugs.openjdk.org/browse/JDK-8323524
src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 684:
> 682: srcImpl.checkAccess(srcFromOffset, srcBytes, true);
> 683: dstImpl.checkAccess(dstFromOffset, dstBytes, true);
> 684: if (dstImpl.equals(srcImpl) && srcFromOffset == dstFromOffset && srcBytes == dstBytes) {
I'm also ok to completely drop this check (or move it into the instance version of the mismatch method). This also needs a test.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17354#issuecomment-1885824510
PR Review Comment: https://git.openjdk.org/jdk/pull/17354#discussion_r1448045022
More information about the core-libs-dev
mailing list