You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks to me that there is one (and only one) way a double release could happen. It is if an exception was thrown in line 211 of NettyAdaptiveCumulator.java as mergeWithCompositeTail only has that line of logic after in.release() on line 207.
This is because after the call to addInput calls mergeWithCompositeTail it immediately sets in = null and the release of in is gated by in != null. However, composite.readerIndex calls AbstractBuffer.readerIndex which can do a checkIndexBounds (default behavior) which can throw an IndexOutOfBoundsException.
It would be good to change
if (in != null) {
in.release();
}
to
if (in != null && in.refCnt() > 0) {
in.release();
}
What version of gRPC-Java are you using?
Version 1.51.0 introduced this issue.
What is your environment?
Any
What did you expect to see?
What did you see instead?
Steps to reproduce the bug
In the case below, NettyAdaptiveCumulator incorrectly releases
ByteBuf in
twice.io.grpc.netty.NettyAdaptiveCumulator.cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in)
cumulation: UnpooledHeapByteBuf(ridx: 9, widx: 14, cap: 14/14)
in: UnpooledHeapByteBuf(ridx: 0, widx: 8, cap: 8/8)
NettyAdaptiveCumulator#mergeWithCompositeTail
is released onceNettyAdaptiveCumulator#cumulate
The text was updated successfully, but these errors were encountered: