Arena/Segment allocator and zero initialized

Remi Forax forax at univ-mlv.fr
Wed Jun 5 18:11:19 UTC 2024


----- Original Message -----
> From: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>
> To: "Jonathan Rosenne" <jr at qsm.co.il>, "panama-dev" <panama-dev at openjdk.org>
> Sent: Wednesday, June 5, 2024 7:57:11 PM
> Subject: Re: Arena/Segment allocator and zero initialized

> On 05/06/2024 18:40, Jonathan Rosenne wrote:
>> Hi,
>>
>> SegmentAllocator is an interface. So is Arena. It should be quite possible to
>> have an derived implementation that call Arena.allocate and zeroizes the memory
>> if this is desired.
> 
> Yes, this is possible but I believe Remi wants to avoid "double
> zeroing", see other thread.
> 
>> In general it is counter-productive if the segment is used for output as
>> zeroizing is CPU intensive..
> Now that you say that, looking back ar Remi's example (which is
> collections backed by memory segment) I'm no longer sure as to why we
> need zeroing.
> 
> Sure, say, a List is created with an initial slab of 1024 bytes, and if
> these bytes are not zeroed we might read "wrong values". But...
> 
> The List interface has a "size". The size starts off at zero. So you
> can't read elements that haven't been inserted yet.
> 
> If that's the case, isn't it true that nobody can read a value _before_
> it has been explicitly set by the user? And, if so, why is zeroing a must?
> 
> (of course I'm not saying that, in general, one should not be able to
> enforce zeroing where that's required, but in this specific case, do we
> need that?)

Yes, you do need it if you only implement List.

My old library had a way to get a list full of zeroes, this library is used at runtime by a language that allows to get the value at an index above the list size but below a capacity.

> 
> Maurizio

Rémi


More information about the panama-dev mailing list