Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of range [1] with length 1 when using AES_DECRYPT #43063

Closed
King-Dylan opened this issue Apr 14, 2023 · 2 comments · Fixed by #43086
Closed

Index out of range [1] with length 1 when using AES_DECRYPT #43063

King-Dylan opened this issue Apr 14, 2023 · 2 comments · Fixed by #43086

Comments

@King-Dylan
Copy link
Contributor

Bug Report

Index out of range [1] with length 1 when using AES_DECRYPT

1. Minimal reproduce step (Required)

create table test (name1 varchar(64),name2 varchar(64));
insert into test values('99FAFD8059A44BC14BCCC70154AC00F3','99FAFD8059A44BC14BCCC70154AC00F3');
SELECT * FROM test WHERE CAST(AES_DECRYPT(UNHEX(name1), 'r��Lu-t�AS�h)%R`') AS CHAR) = '00' AND CAST(AES_DECRYPT(UNHEX(name2), 'r��`') AS CHAR) = '1';

2. What did you expect to see? (Required)

No error

3. What did you see instead (Required)

ERROR 1105 (HY000): runtime error: index out of range [1] with length 1
github.com/pingcap/tidb/executor.(*recordSet).Next.func1
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:149
runtime.gopanic
\t/usr/local/go/src/runtime/panic.go:884
runtime.goPanicIndex
\t/usr/local/go/src/runtime/panic.go:113
github.com/pingcap/tidb/util/chunk.(*Column).GetBytes
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/column.go:588
github.com/pingcap/tidb/expression.(*builtinAesDecryptSig).vecEvalString
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/builtin_encryption_vec.go:73
github.com/pingcap/tidb/expression.(*ScalarFunction).VecEvalString
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/scalar_function.go:58
github.com/pingcap/tidb/expression.(*builtinInternalFromBinarySig).vecEvalString
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/builtin_convert_charset.go:198
github.com/pingcap/tidb/expression.(*ScalarFunction).VecEvalString
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/scalar_function.go:58
github.com/pingcap/tidb/expression.(*builtinCastStringAsStringSig).vecEvalString
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/builtin_cast_vec.go:1895
github.com/pingcap/tidb/expression.(*ScalarFunction).VecEvalString
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/scalar_function.go:58
github.com/pingcap/tidb/expression.(*builtinEQStringSig).vecEvalInt
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/builtin_compare_vec_generated.go:1003
github.com/pingcap/tidb/expression.(*ScalarFunction).VecEvalInt
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/scalar_function.go:48
github.com/pingcap/tidb/expression.(*builtinLogicOrSig).vecEvalInt
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/builtin_op_vec.go:77
github.com/pingcap/tidb/expression.(*ScalarFunction).VecEvalInt
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/scalar_function.go:48
github.com/pingcap/tidb/expression.EvalExpr
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/expression.go:574
github.com/pingcap/tidb/expression.VecEvalBool
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/expression/expression.go:369

4. What is your TiDB version? (Required)

master

@King-Dylan King-Dylan added the type/bug The issue is confirmed as a bug. label Apr 14, 2023
@bb7133 bb7133 added the sig/sql-infra SIG: SQL Infra label Apr 14, 2023
@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Apr 15, 2023

The first EQ expr filter all rows(Sel in Chunk is not nil, but length is zero, check here), but builtinAesDecrypt in the second EQ expr assume the result of its child result is not empty, and try to get the first byte of its child result(check here). So we got this panic.

@guo-shaoge
Copy link
Collaborator

You can disble vectorized expr(set @@tidb_enable_vectorized_expression = off ) as a workround

@ti-chi-bot ti-chi-bot added may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Apr 17, 2023
@lcwangchao lcwangchao self-assigned this Apr 17, 2023
@lcwangchao lcwangchao added affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 and removed may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants