RFR: 8324858: [vectorapi] Bounds checking issues when accessing memory segments

Paul Sandoz psandoz at openjdk.org
Mon Jan 29 23:19:55 UTC 2024


The implementation of method `VectorSpecies::fromMemorySegment`, in `AbstractSpecies::fromMemorySegment`, neglects to perform bounds checks on the offset argument when the method is compiled by C2 (bounds checks are performed when interpreted and by C1).

This is an oversight and explicit bounds checks are required, as is already case for the other load and store memory access methods (including storing to memory memory segments).

The workaround is to call the static method `{T}Vector::fromMemorySegment`.

The fix is for the implementation(s) of `VectorSpecies::fromMemorySegment` to do the same and call `{T}Vector::fromMemorySegment`, following the same pattern for implementations of `VectorSpecies::fromArray`.

The tests have been conservatively updated to call the species access method were possible in the knowledge that calls the vector access method (the tests were intended to test out of bounds access when compiled by C2).

Thinking ahead its tempting to remove the species access methods, simplifying functionality that is duplicated.

-------------

Commit messages:
 - Merge branch 'master' into v-load-segment-bounds-checks
 - 8324858: [vectorapi] Bounds checking issues when accessing memory segments

Changes: https://git.openjdk.org/jdk/pull/17621/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17621&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8324858
  Stats: 165 lines in 39 files changed: 56 ins; 8 del; 101 mod
  Patch: https://git.openjdk.org/jdk/pull/17621.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17621/head:pull/17621

PR: https://git.openjdk.org/jdk/pull/17621


More information about the core-libs-dev mailing list