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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Sep 30 12:08:57 UTC 2021


> 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).

Maurizio Cimadamore has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:

 - Merge branch 'foreign-memaccess+abi' into fixScopedOperationTest
 - Fix TestScopedOperations

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

Changes: https://git.openjdk.java.net/panama-foreign/pull/587/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=587&range=01
  Stats: 49 lines in 5 files changed: 19 ins; 7 del; 23 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/587.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/587/head:pull/587

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


More information about the panama-dev mailing list