[code-reflection] RFR: Explicit Arena passing to Tensor construction and Session execution [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Mar 4 14:09:10 UTC 2025
On Tue, 4 Mar 2025 13:58:46 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>>
>> using Arena.ofConfined() instance for each individual test in CNNTest
>
> cr-examples/onnx/src/main/java/oracle/code/onnx/OnnxRuntime.java line 315:
>
>> 313: private final MemorySegment sessionAddress;
>> 314:
>> 315: private Session(Arena arena, MemorySegment sessionAddress) {
>
> I don't think this is an improvement? The idea behind the current code is that a session has a lifetime (managed by an arena) -- and all the resources allocated during `run` are associated to that same lifetime.
>
> In the current code, `arena` is passed as parameter to both the constructor and `run` -- which means you could pass two different arenas, and that would result in subtle use-after-free issues.
(I see that this is done to cache the session --- but IMHO this feels like the caching tail is wagging the API dog a bit).
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/337#discussion_r1979523003
More information about the babylon-dev
mailing list