Skip to content

MSSQL query throws io.netty.handler.codec.DecoderException caused by IndexOutOfBoundsException #1032

Closed
@gbadner

Description

@gbadner

Version

4.1.3

Context

Using MSSQL, the following query:

select table_name as TABLE_NAME, column_name as COLUMN_NAME, data_type as TYPE_NAME, null as COLUMN_SIZE, 
             null as DECIMAL_DIGITS, is_nullable as IS_NULLABLE, null as DATA_TYPE 
from information_schema.columns 
order by table_catalog, table_schema, table_name, column_name, ordinal_position

throws:

io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))

Full stacktrace is below.

The following query fails intermittently with the same exception:

select convert( nvarchar(128), table_name ) as TABLE_NAME, convert( nvarchar(128), column_name ) as COLUMN_NAME,
         convert( nvarchar(128), data_type ) as TYPE_NAME, null as COLUMN_SIZE, null as DECIMAL_DIGITS, 
         convert( varchar(3), is_nullable ) as IS_NULLABLE, null as DATA_TYPE 
from information_schema.columns 
order by table_catalog, table_schema, table_name, column_name, ordinal_position

The following query succeeds:

select table_name as TABLE_NAME, column_name as COLUMN_NAME, data_type as TYPE_NAME, null as COLUMN_SIZE,
             is_nullable as IS_NULLABLE
from information_schema.columns
order by table_catalog, table_schema, table_name, column_name, ordinal_position

Do you have a reproducer?

Yes, but it is fairly complicated involving Hibernate ORM and Reactive PRs:
ORM: hibernate/hibernate-orm#4177
Reactive: hibernate/hibernate-reactive#945

It would probably be easier to add a test to MSSQLQueriesTest. I'm having trouble getting tests to run locally. I'll see if I can get that working tomorrow.

Steps to reproduce

  1. ...
  2. ...
  3. ...

Extra

  • Fedora
  • JDK 1.8

Full stacktrace:

java.util.concurrent.CompletionException: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977) ~[?:1.8.0_172-ea]
	at io.vertx.core.Future.lambda$toCompletionStage$2(Future.java:362) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.QueryResultBuilder.tryFail(QueryResultBuilder.java:118) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.core.Promise.fail(Promise.java:89) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.Promise.handle(Promise.java:53) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.Promise.handle(Promise.java:29) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.onFailure(PromiseImpl.java:54) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl$ListenerArray.onFailure(FutureImpl.java:268) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.onFailure(PromiseImpl.java:54) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:43) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.command.CommandResponse.fire(CommandResponse.java:46) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.SocketConnectionBase.handleMessage(SocketConnectionBase.java:279) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.SocketConnectionBase.lambda$init$0(SocketConnectionBase.java:98) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.NetSocketImpl.lambda$new$1(NetSocketImpl.java:97) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:240) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:130) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.NetSocketImpl.lambda$handleMessage$9(NetSocketImpl.java:390) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:50) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.ContextImpl.emit(ContextImpl.java:274) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:22) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:389) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:155) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:154) [vertx-core-4.1.3.jar:4.1.3]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.vertx.mssqlclient.impl.codec.TdsMessageCodec.fail(TdsMessageCodec.java:58) [vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.vertx.mssqlclient.impl.codec.TdsMessageCodec.exceptionCaught(TdsMessageCodec.java:48) [vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:143) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:381) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) [netty-common-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.67.Final.jar:4.1.67.Final]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172-ea]
Caused by: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:477) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.67.Final.jar:4.1.67.Final]
	... 15 more
Caused by: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))
	at io.netty.buffer.AbstractByteBuf.checkRangeBounds(AbstractByteBuf.java:1390) ~[netty-buffer-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.buffer.AbstractByteBuf.checkIndex0(AbstractByteBuf.java:1397) ~[netty-buffer-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.buffer.PooledSlicedByteBuf.slice(PooledSlicedByteBuf.java:106) ~[netty-buffer-4.1.67.Final.jar:4.1.67.Final]
	at io.vertx.mssqlclient.impl.codec.TdsPacketDecoder.decode(TdsPacketDecoder.java:38) ~[vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.vertx.mssqlclient.impl.codec.TdsPacketDecoder.decode(TdsPacketDecoder.java:21) ~[vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:332) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.67.Final.jar:4.1.67.Final]
	... 15 more

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions