-
Enhancement
-
Resolution: Fixed
-
P3
-
19
-
None
Consider the following memory access var handle creation:
MemoryLayout layout = MemoryLayout.sequenceLayout(5, JAVA_INT);
VarHandle VH = layout.varHandle(PathElement.sequenceLayout());
And consider the following access expression:
VH.get(segment, 10);
Now, clearly, the index provided by the client (10) is outside the bound of the sequence layout used to construct the var handle. Currently the API does not report this as a direct error. Instead it allows access, which then will succeed or fail depending on the segment size. If the above expression is used to dereference a portion of a bigger segment, not detecting the out-of-bounds access might result in corrupting unrelated parts of the memory segment (think about struct access, where setting a field accidentally sets a different field).
MemoryLayout layout = MemoryLayout.sequenceLayout(5, JAVA_INT);
VarHandle VH = layout.varHandle(PathElement.sequenceLayout());
And consider the following access expression:
VH.get(segment, 10);
Now, clearly, the index provided by the client (10) is outside the bound of the sequence layout used to construct the var handle. Currently the API does not report this as a direct error. Instead it allows access, which then will succeed or fail depending on the segment size. If the above expression is used to dereference a portion of a bigger segment, not detecting the out-of-bounds access might result in corrupting unrelated parts of the memory segment (think about struct access, where setting a field accidentally sets a different field).
- csr for
-
JDK-8287293 Add bound check in indexed memory access var handle
-
- Closed
-