ptupitsyn commented on a change in pull request #8483:
URL: https://github.com/apache/ignite/pull/8483#discussion_r533428348
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
##########
@@ -292,7 +233,8 @@ private ClientRequestFuture send(ClientOperation op,
Consumer<PayloadOutputChann
req.writeInt(0, req.position() - 4); // Actual size.
- write(req.array(), req.position());
+ // arrayCopy is required, because buffer is pooled, and write is
async.
+ write(req.arrayCopy(), req.position());
Review comment:
`PayloadOutputChannel` creates `BinaryHeapOutputStream`, which uses
`BinaryMemoryAllocator.THREAD_LOCAL.chunk()`. This thread-local chunk will be
released as soon as we leave the scope, because `PayloadOutputChannel` is
wrapped in a try-with-resources block. However, `write` passes the buffer to
the NIO framework, which may process it later, causing "use-after-free" of
sorts.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]