eclipse-vertx / vertx-grpc

Development of the gRPC component for Eclipse Vert.x
Eclipse Public License 2.0
37 stars 23 forks source link

Investigate suspicious ByteBuf allocation #98

Closed vietj closed 1 month ago

vietj commented 1 month ago

Caught this in CI:

SEVERE: LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 
Created at:
    io.netty.buffer.UnpooledByteBufAllocator.newDirectBuffer(UnpooledByteBufAllocator.java:96)
    io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:188)
    io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:179)
    io.netty.buffer.AbstractByteBufAllocator.buffer(AbstractByteBufAllocator.java:116)
    io.netty.handler.codec.base64.Base64.encode(Base64.java:108)
    io.netty.handler.codec.base64.Base64.encode(Base64.java:100)
    io.netty.handler.codec.base64.Base64.encode(Base64.java:80)
    io.netty.handler.codec.base64.Base64.encode(Base64.java:74)
    io.vertx.grpc.server.impl.GrpcServerResponseImpl.encodeMessage(GrpcServerResponseImpl.java:274)
    io.vertx.grpc.server.impl.GrpcServerResponseImpl.writeMessage(GrpcServerResponseImpl.java:267)
    io.vertx.grpc.server.impl.GrpcServerResponseImpl.writeMessage(GrpcServerResponseImpl.java:123)
    io.vertx.grpc.common.impl.WriteStreamAdapter.write(WriteStreamAdapter.java:47)
    io.vertx.grpc.server.impl.GrpcServiceBridgeImpl$ServerCallImpl.sendMessage(GrpcServiceBridgeImpl.java:169)
    io.grpc.ForwardingServerCall.sendMessage(ForwardingServerCall.java:32)
    io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onNext(ServerCalls.java:380)
    io.vertx.grpc.server.web.TestServiceImpl.streamingCall(TestServiceImpl.java:58)
    io.vertx.grpcweb.TestServiceGrpc$MethodHandlers.invoke(TestServiceGrpc.java:335)
    io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
    io.vertx.grpc.server.impl.GrpcServiceBridgeImpl$ServerCallImpl$1.handleClose(GrpcServiceBridgeImpl.java:100)
    io.vertx.grpc.common.impl.ReadStreamAdapter.lambda$init$1(ReadStreamAdapter.java:33)
    io.vertx.grpc.common.impl.GrpcReadStreamBase.handleEnd(GrpcReadStreamBase.java:195)
    io.vertx.grpc.common.impl.GrpcReadStreamBase.lambda$init$3(GrpcReadStreamBase.java:83)
    io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:255)
    io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:134)
    io.vertx.grpc.common.impl.GrpcReadStreamBase.lambda$init$0(GrpcReadStreamBase.java:72)
    io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:237)
    io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:219)
    io.vertx.core.http.impl.HttpEventHandler.handleEnd(HttpEventHandler.java:76)
    io.vertx.core.http.impl.Http1xServerRequest.onEnd(Http1xServerRequest.java:541)
    io.vertx.core.http.impl.Http1xServerRequest$1.handleMessage(Http1xServerRequest.java:104)
    io.vertx.core.net.impl.InboundMessageQueue.test(InboundMessageQueue.java:73)
    io.vertx.core.streams.impl.InboundReadQueue.drain(InboundReadQueue.java:250)
    io.vertx.core.streams.impl.InboundReadQueue.drain(InboundReadQueue.java:224)
    io.vertx.core.net.impl.InboundMessageQueue.drainInternal(InboundMessageQueue.java:164)
    io.vertx.core.net.impl.InboundMessageQueue.drain(InboundMessageQueue.java:144)
    io.vertx.core.http.impl.Http1xServerRequest.handleEnd(Http1xServerRequest.java:153)
    io.vertx.core.http.impl.Http1xServerConnection.onEnd(Http1xServerConnection.java:197)
    io.vertx.core.http.impl.Http1xServerConnection.onContent(Http1xServerConnection.java:188)
    io.vertx.core.http.impl.Http1xServerConnection.handleOther(Http1xServerConnection.java:173)
    io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:166)
    io.vertx.core.net.impl.VertxConnection.read(VertxConnection.java:239)
    io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:153)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:87)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61)
    io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1407)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
    io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    java.base/java.lang.Thread.run(Thread.java:829)
vietj commented 1 month ago

cc @tsegismont