[foreign-memaccess+abi] Integrated: TestScopedOperations does not work as expected
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Sep 30 12:31:04 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).
This pull request has now been integrated.
Changeset: 45111908
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.java.net/panama-foreign/commit/451119083514a197f055babb567596ef07c27d2f
Stats: 49 lines in 5 files changed: 19 ins; 7 del; 23 mod
TestScopedOperations does not work as expected
Reviewed-by: jvernee
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/587
More information about the panama-dev
mailing list