[foreign-memaccess+abi] RFR: TestScopedOperations does not work as expected

Jorn Vernee jvernee at openjdk.java.net
Thu Sep 30 11:48:52 UTC 2021


On Wed, 29 Sep 2021 21:16:39 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> When Julia started to work on the `MemorySegment::overlap` API, she noticed (thanks!) an issue with the TestScopedOperation. Essentially this test checks that calling methods on various objects should be scope-safe - that is, it shouldn't be possible to call certain methods (e.g. MemorySegment::address) if the scope associated with the object is closed, or from a thread other than the owning thread.
> 
> The test had a fatal flaw, which was probably introduced when we moved to the `ResourceScope` API. Since the scoped operation creates the desired object (e.g. a segment) and then performs an operation on it, and since that operation is performed _after_ the scope has been closed, as a result, all tests trivially fail as expected, since the object cannot be created in the first place (the scope is closed!!).
> 
> The solution is to separate the logic for creating the object from the logic for testing the scoped operation. In fixing the test I realized that the test was running two combinations which didn't make sense (prefixAllocator::allocate, and segment::spliterator, neither of which is scoped), and found a bug in the VaList implementation - for VaList::skip, which was missing a scope check (which this patch also addresses).

Looks like you have some merge conflicts as well

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SegmentAllocator.java line 29:

> 27: 
> 28: import jdk.internal.foreign.ArenaAllocator;
> 29: import jdk.internal.foreign.ResourceScopeImpl;

Spurious import?

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

Marked as reviewed by jvernee (Committer).

PR: https://git.openjdk.java.net/panama-foreign/pull/587


More information about the panama-dev mailing list