RFR: 8358537: (bf) JavaNioAccess::getBufferAddress bypasses direct buffer MemorySession state check
Brian Burkhalter
bpb at openjdk.org
Wed Jun 4 00:43:20 UTC 2025
On Tue, 3 Jun 2025 23:57:21 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> I thin it's running into this method in DirectBufferX:
>>
>> public long address() {
>> MemorySessionImpl session = session();
>> if (session != null) {
>> if (session.ownerThread() == null && session.isCloseable()) {
>> throw new UnsupportedOperationException("ByteBuffer derived from closeable shared sessions not supported");
>> }
>
> Oh, I see. IIRC this is why the shared secrets are bypassing the `address()` method. For shared arenas the caller is supposed to do an acquire/release, and then use shared secrets to get the buffer address, bypassing this check.
>
> @minborg recently did some work to change over uses of `DirectBuffer::address` in https://github.com/openjdk/jdk/pull/25324 and https://github.com/openjdk/jdk/pull/25321
>
> If ByteBuffers derived from segments with shared arenas no longer work with this patch, that seems like a regression to me.
It could be. More study is clearly needed. This is related to #25531.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25631#discussion_r2125195256
More information about the nio-dev
mailing list