RFR: 8275063: Implementation of Foreign Function & Memory API (Second incubator) [v12]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Nov 2 19:49:16 UTC 2021

On Tue, 2 Nov 2021 18:48:57 GMT, Maurizio Cimadamore <mcimadamore at 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

More information about the security-dev mailing list