mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8278897: Alignment of heap segments is not enforced correctly
Reviewed-by: jvernee
This commit is contained in:
parent
0f4807e8fe
commit
9d43d25da8
20 changed files with 600 additions and 34 deletions
|
@ -50,7 +50,7 @@ abstract class MemoryAccessVarHandleBase extends VarHandle {
|
|||
this.alignmentMask = alignmentMask;
|
||||
}
|
||||
|
||||
static IllegalStateException newIllegalStateExceptionForMisalignedAccess(long address) {
|
||||
return new IllegalStateException("Misaligned access at address: " + address);
|
||||
static IllegalArgumentException newIllegalArgumentExceptionForMisalignedAccess(long address) {
|
||||
return new IllegalArgumentException("Misaligned access at address: " + address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ final class MemoryAccessVarHandle$Type$Helper extends MemoryAccessVarHandleBase
|
|||
static long offset(boolean skipAlignmentMaskCheck, MemorySegmentProxy bb, long offset, long alignmentMask) {
|
||||
long address = offsetNoVMAlignCheck(skipAlignmentMaskCheck, bb, offset, alignmentMask);
|
||||
if ((address & VM_ALIGN) != 0) {
|
||||
throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address);
|
||||
throw MemoryAccessVarHandleBase.newIllegalArgumentExceptionForMisalignedAccess(address);
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
@ -115,14 +115,15 @@ final class MemoryAccessVarHandle$Type$Helper extends MemoryAccessVarHandleBase
|
|||
static long offsetNoVMAlignCheck(boolean skipAlignmentMaskCheck, MemorySegmentProxy bb, long offset, long alignmentMask) {
|
||||
long base = bb.unsafeGetOffset();
|
||||
long address = base + offset;
|
||||
long maxAlignMask = bb.maxAlignMask();
|
||||
if (skipAlignmentMaskCheck) {
|
||||
//note: the offset portion has already been aligned-checked, by construction
|
||||
if ((base & alignmentMask) != 0) {
|
||||
throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address);
|
||||
if (((base | maxAlignMask) & alignmentMask) != 0) {
|
||||
throw MemoryAccessVarHandleBase.newIllegalArgumentExceptionForMisalignedAccess(address);
|
||||
}
|
||||
} else {
|
||||
if ((address & alignmentMask) != 0) {
|
||||
throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address);
|
||||
if (((address | maxAlignMask) & alignmentMask) != 0) {
|
||||
throw MemoryAccessVarHandleBase.newIllegalArgumentExceptionForMisalignedAccess(address);
|
||||
}
|
||||
}
|
||||
return address;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue