[foreign-abi] RFR 8232628: foreign-abi usability issues
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Oct 18 17:51:32 UTC 2019
On 18/10/2019 18:36, John Rose wrote:
> On Oct 18, 2019, at 10:23 AM, Maurizio Cimadamore
> <maurizio.cimadamore at oracle.com
> <mailto:maurizio.cimadamore at oracle.com>> wrote:
>>
>> which means we should probably create a NOTHING memory segment to
>> prevent slicing
>
> Maybe it’s enough to have a special zero-length segment.
>
> (Can I make such a segment by slicing? Answer should probably be “yes”.)
You can indeed slice your way up into a zero-length segment.
MemorySegment zero = MemorySegment.ofNative(10).slice(0, 0);
But... a segment also has a 'base' object and a 'min' offset attached to it.
A NULL address is a specific address which can be thought of as the base
address of a segment whose base is null and whose min offset is zero
And obtaining such a segment is 'unsafe' (because that's the EVERYTHING
segment).
So... "everything" is unsafe, but "nothing" is trivially safe (even
though it can be derived from "everything").
But "nothing" != "zero length"
In fact you might have _infinitely many_ distinct "zero length" segment,
but only one true "nothing" one.
Makes sense?
Maurizio
More information about the panama-dev
mailing list