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

Incorrect swaping column leads to nil pointer #53713

Closed
xzhangxian1008 opened this issue May 31, 2024 · 3 comments · Fixed by #53794 · May be fixed by #53842
Closed

Incorrect swaping column leads to nil pointer #53713

xzhangxian1008 opened this issue May 31, 2024 · 3 comments · Fixed by #53794 · May be fixed by #53842
Assignees
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. impact/panic severity/major sig/execution SIG execution sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@xzhangxian1008
Copy link
Contributor

xzhangxian1008 commented May 31, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. source valid.txt,
    valid.txt
  2. source error.txt,
    error.txt

If no error happens, try it again.

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 [0] with length 0

4. What is your TiDB version? (Required)

0afe54d

@xzhangxian1008 xzhangxian1008 added the type/bug The issue is confirmed as a bug. label May 31, 2024
@xzhangxian1008
Copy link
Contributor Author

/severity major

@xzhangxian1008
Copy link
Contributor Author

xzhangxian1008 commented May 31, 2024

panic stack:

runtime error: index out of range [0] with length 0
github.com/pingcap/errors.AddStack
	/DATA/disk3/xzx/go/path/pkg/mod/github.com/pingcap/[email protected]/errors.go:178
github.com/pingcap/errors.Trace
	/DATA/disk3/xzx/go/path/pkg/mod/github.com/pingcap/[email protected]/juju_adaptor.go:15
github.com/pingcap/tidb/pkg/util.GetRecoverError
	/DATA/disk3/xzx/tidb/pkg/util/util.go:304
github.com/pingcap/tidb/pkg/executor/aggregate.recoveryHashAgg
	/DATA/disk3/xzx/tidb/pkg/executor/aggregate/agg_util.go:91
github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggPartialWorker).run.func1
	/DATA/disk3/xzx/tidb/pkg/executor/aggregate/agg_hash_partial_worker.go:194
runtime.gopanic
	/DATA/disk3/xzx/go/src/runtime/panic.go:920
runtime.goPanicIndex
	/DATA/disk3/xzx/go/src/runtime/panic.go:114
github.com/pingcap/tidb/pkg/util/chunk.(*Column).IsNull
	/DATA/disk3/xzx/tidb/pkg/util/chunk/column.go:180
github.com/pingcap/tidb/pkg/util/codec.HashGroupKey
	/DATA/disk3/xzx/tidb/pkg/util/codec/codec.go:1247
github.com/pingcap/tidb/pkg/executor/aggregate.GetGroupKey
	/DATA/disk3/xzx/tidb/pkg/executor/aggregate/agg_util.go:149
github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggPartialWorker).updatePartialResult
	/DATA/disk3/xzx/tidb/pkg/executor/aggregate/agg_hash_partial_worker.go:260
github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggPartialWorker).fetchChunkAndProcess
	/DATA/disk3/xzx/tidb/pkg/executor/aggregate/agg_hash_partial_worker.go:108
github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggPartialWorker).run
	/DATA/disk3/xzx/tidb/pkg/executor/aggregate/agg_hash_partial_worker.go:210
runtime.goexit
	/DATA/disk3/xzx/go/src/runtime/asm_amd64.s:1650

After investigation, we can see that the nullBitmap and data in the col are empty at pkg/util/codec/codec.go:1247 which directly leads to the panic of sql.

The empty of nullBitmap and data is caused by the incorrect swap at line pkg/expression/evaluator.go:31. There are two columns in input chunk, they are separate at idx1 and idx2 and both hold the same column pointer. When we want to swap idx2 col of input chunk with idx0 column of output chunk, idx1 col of input chunk will be incorrectly swapped and leads to the nullBitmap and data of idx1 column of input to be empty. Then idx1 column of input will be swapped with idx3 column of output which makes the nullBitmap and data fields be empty in the ouput chunk.

@xzhangxian1008
Copy link
Contributor Author

/sig planner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. impact/panic severity/major sig/execution SIG execution sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
5 participants