[foreign-memaccess+abi] Integrated: 8265974: ResourceScope code does not handle close vs. add races well
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Mon Apr 26 22:50:59 UTC 2021
On Mon, 26 Apr 2021 13:15:40 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This PR is motivated by the discussion in:
>
> https://git.openjdk.java.net/panama-foreign/pull/519
>
> There seems to be an issue (at least conceptually) in that the code which adds a new cleanup can, in principle, replace CLOSED_LIST with a new cleanup action, which then breaks the list invariants.
>
> While some fixes are possible, I believe that this part of the code is too complex and there's really no reason as to why we would want to allow CLOSE and ADD to happen in parallel with as few synchronization as possible.
>
> Since we already have a way to prevent a scope from being closed, it only seems fair that `addCloseAction` should defend against scope closure using acquire. Under this new, simplified world, in the shared case we only have to worry about add vs. add races, as add vs. close is no longer possible.
>
> I've re-ran the benchmark `ResourceScopeClose` and noticed no performance impact of this code simplification. So I think it would be better to make the code "dumber" but more obviously correct, rather than chasing dubious micro optimizations whose correctess we're not 100% sure about.
This pull request has now been integrated.
Changeset: c529f18a
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.java.net/panama-foreign/commit/c529f18a
Stats: 79 lines in 4 files changed: 26 ins; 46 del; 7 mod
8265974: ResourceScope code does not handle close vs. add races well
Reviewed-by: psandoz
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/520
More information about the panama-dev
mailing list