On Tue, 2 Nov 2021 18:48:57 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/ArenaAllocator.java
>>  line 88:
>> 
>>> 86:                     if (size > arenaSize) {
>>> 87:                         throw new OutOfMemoryError();
>>> 88:                     }
>> 
>> Isn't this already covered by the `finally` block? Also, this seems to be 
>> checking the unaltered `size`, which I think should have been already done 
>> at the end of the previous `allocate` call right?
>
> I'll have to think some more about this. I don't think this is covered inside 
> the block - that is, the block tries to allocate, and then in the finally we 
> throw if we realized we've allocated too much.

What is missing, I think, is a check (size > arenaSize) at the beginning of the 
method (we only check this in one of the paths). But we need to check before 
and after, I think, as it is possible to allocate a segment and then realize 
that we ended up overflowing the arena size.

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

PR: https://git.openjdk.java.net/jdk/pull/5907

Reply via email to