Skip to content

Driver throws ArrayIndexOutOfBoundsException from internal code #2222

@qingwei91

Description

@qingwei91

Driver version

  • 12.4.1-jre11
  • 12.2.0-jre11
  • 11.2.1-jre11

SQL Server version

Microsoft SQL Server 2019 (RTM-CU16) (KB5011644) - 15.0.4223.1 (X64)

Client Operating System

Linux (Redhat)

JAVA/JVM version

JDK 11

Table schema

Irrelevant

Problem description

When trying to call a stored procedure that uses Table Valued Parameters, the driver throws exception with the following stack trace.

I was able to write less rows using the same code, but I cant pinpoint if the problem is due to data size, this happens when I was passing 100k++ rows using table valued params.

If there's something wrong with the input data, I expect driver to report something that's more actionable

Expected behavior

It should either not throw or provide clearer error message if there's indeed a user error.

Actual behavior

I get error from System.arraycopy, coming deep inside the driver.

Error message/stack trace

Caused by: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 26 out of bounds for byte[17]
	at java.base/java.lang.System.arraycopy(Native Method)
	at com.microsoft.sqlserver.jdbc.TDSWriter.writeInternalTVPRowValues(IOBuffer.java:5118)
	at com.microsoft.sqlserver.jdbc.TDSWriter.writeTVPRows(IOBuffer.java:4995)
	at com.microsoft.sqlserver.jdbc.TDSWriter.writeTVP(IOBuffer.java:4908)
	at com.microsoft.sqlserver.jdbc.DTV$SendByRPCOp.execute(dtv.java:386)
	at com.microsoft.sqlserver.jdbc.DTV.executeOp(dtv.java:1657)
	at com.microsoft.sqlserver.jdbc.DTV.sendByRPC(dtv.java:1902)
	at com.microsoft.sqlserver.jdbc.Parameter.sendByRPC(Parameter.java:1189)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.sendParamsByRPC(SQLServerPreparedStatement.java:757)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doPrepExec(SQLServerPreparedStatement.java:1158)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:643)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:567)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7675)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4137)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:272)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:246)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:544)

Any other details that can be helpful

Add any other context about the problem here.

JDBC trace logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed Issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions