RFR: 8316337: (bf) Concurrency issue in DirectByteBuffer.Deallocator [v3]
Alan Bateman
alanb at openjdk.org
Tue Sep 19 06:37:39 UTC 2023
On Tue, 19 Sep 2023 00:56:13 GMT, Chen Liang <liach at openjdk.org> wrote:
>> `address` can't be 0 if asserts a enabled. Might `address` be 0 if asserts **_aren't_** enabled?
>
> This constructor is only used from DirectXBuffer constructors (line 142), and the passed address is the return value of `Unsafe.allocateMemory` (line 129). We can trust `address` as long as we trust the unsafe method.
> `address` can't be 0 if asserts a enabled. Might `address` be 0 if asserts **_aren't_** enabled?
No, the address is always non-0. The assert is good, the check if it's 0 can be removed. If you allocateDirect(0) then it will adjusted to allocate 1 byte so the address is non-0.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15784#discussion_r1329637509
More information about the nio-dev
mailing list