[foreign-memaccess+abi] RFR: 8302556: Find better way to create unsafe native segments [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Feb 15 19:16:47 UTC 2023


On Wed, 15 Feb 2023 18:06:21 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/UpcallStubs.java line 60:
>> 
>>> 58:             }
>>> 59:         });
>>> 60:         return MemorySegment.ofAddress(entry).reinterpret(arena.scope(), null);
>> 
>> In principle we could just express this using public API if we tweak the semantics for cleanup action to always run in case the scope is found to be already closed.
>
> Yeah, I think that might be better as semantics in general. If the attach fails, don't leak, and run the cleanup action.

Not super sure how to specify this though - e.g. should we say that the cleanup is always run when the method completes abnormally? Possible failure causes are:
* the scope is no longer alive (this is what we care about)
* the size is negative
* the method is called on a segment that is not native
* the method is called and restricted access is not enabled.

Note 100% sure *when* we should say we would attempt to run the cleanup action. Kind of tempted leave it as is.

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

PR: https://git.openjdk.org/panama-foreign/pull/797


More information about the panama-dev mailing list