RFR: JDK-8264111 (fs) Leaking NativeBuffers in case of errors during UnixUserDefinedFileAttributeView.read/write [v2]
Sebastian Stenzel
github.com+1204330+overheadhunter at openjdk.java.net
Thu Mar 25 11:57:57 UTC 2021
On Thu, 25 Mar 2021 11:35:51 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Sebastian Stenzel has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Added @Override annotation to write(String, ByteBuffer)
>
> src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java line 174:
>
>> 172: if (dst instanceof sun.nio.ch.DirectBuffer buf) {
>> 173: long address = buf.address() + pos;
>> 174: int n = read(name, address, rem);
>
> We need to add reachabilityFence here, don't mind if we do it now while changing this code or later.
> That is, it should be try { n = read(name, address, rem); } finally { Reference.reachabilityFence(buf); }
Never heard of this before, just read the docs the first time. Do I get this right, that this helps to protect against instant finalization of the buffer in e.g. `attrView.read("foo", ByteBuffer.allocateDirect(42))`?
What about the `write` case?
-------------
PR: https://git.openjdk.java.net/jdk/pull/3171
More information about the nio-dev
mailing list