RFR: 8324972: (bf) Make DirectByteBuffer.Deallocator idempotent [v4]

Alan Bateman alanb at openjdk.org
Mon Feb 12 10:14:04 UTC 2024


On Mon, 12 Feb 2024 09:48:15 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

> Is the Deallocator abstraction designed to be thread safe as advocated in https://bugs.openjdk.org/browse/JDK-8316337 ? Is it correct and proper design, hence good practice, as per the original logic, that Deallocator guard against improper release of its encapsulated native memory more than once?

Deallocator is a function that is intended to be run at most once. Mostly it will be called from the Cleaner thread but there is backdoor with Unsafe.invokeCleaner so it may be run by some other thread. Cleaner is designed, specified, and implemented, to invoke the cleaning action at most once, so Deallocator.run should run at most once. If there is a scenario where Deallocator.run can be run more than once then it is serious bug. I'm not opposed to make it idempotent but I'm concerned this is masking an issue elsewhere. If you have identified a scenario where it can be run more than once then it would be useful to get an outline so it can be studied.

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

PR Comment: https://git.openjdk.org/jdk/pull/17647#issuecomment-1938378881


More information about the nio-dev mailing list