On Tue, 6 Jun 2023 16:22:41 GMT, Jorn Vernee <jver...@openjdk.org> wrote:
> Fix the bug mentioned in the JBS issue. > > The implementation is updated to slice the capture state segment using the > capture state layout. This checks both that the segment is big enough, and > that it is properly aligned. > > Additionally, I added a check for `MS::NULL` since this is also an illegal > value we can catch early. > > Test cases are added for all three invalid values. > > Testing: `jdk_foreign` test suite. Looks good src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 114: > 112: MH_CHECK_SYMBOL = lookup.findStatic(SharedUtils.class, > "checkSymbol", > 113: methodType(void.class, MemorySegment.class)); > 114: MH_SLICE_CAPTURE_SEGMENT = > lookup.findStatic(SharedUtils.class, "checkCaptureSegment", Is the name of the field correct? test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java line 152: > 150: {Arena.ofAuto().allocate(1), > IndexOutOfBoundsException.class, ".*Out of bound access on segment.*"}, > 151: {MemorySegment.NULL, IllegalArgumentException.class, > ".*Capture segment is NULL.*"}, > 152: > {Arena.ofAuto().allocate(Linker.Option.captureStateLayout().byteSize() + > 3).asSlice(3), // misaligned This last one is very nice! ------------- Marked as reviewed by mcimadamore (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/14339#pullrequestreview-1465703809 PR Review Comment: https://git.openjdk.org/jdk/pull/14339#discussion_r1220030249 PR Review Comment: https://git.openjdk.org/jdk/pull/14339#discussion_r1220033212