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

runtime error : invalid memory address or nil pointer dereference #33912

Closed
River2000i opened this issue Apr 13, 2022 · 4 comments
Closed

runtime error : invalid memory address or nil pointer dereference #33912

River2000i opened this issue Apr 13, 2022 · 4 comments
Assignees
Labels
affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@River2000i
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1;
create table t1(a int AUTO_INCREMENT primary key, b int, c varbinary(20), index(b), index(c));
select count(*) from t1 group by a having ifnull(avg(`b`), min(`c`));

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

no error

3. What did you see instead (Required)

mysql> drop table if exists t1;
Query OK, 0 rows affected (1.93 sec)

mysql> create table t1(a int AUTO_INCREMENT primary key, b int, c varbinary(20), index(b), index(c));
Query OK, 0 rows affected (0.11 sec)

mysql> insert into t1(b, c) value('10', '53313630773976704648');
Query OK, 1 row affected (0.06 sec)

mysql> select count(*) from t1 group by a having ifnull(avg(`b`), min(`c`));
ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference
[ERROR] [conn.go:1031] ["connection running loop panic"] [conn=445] [lastSQL="select /*+ stream_agg() */ avg( isnull( null ) or null ) from table_20_latin1_undef as t1 group by t1. `pk` having ifnull(min(distinct `col_varchar(20)_undef_signed`) <=> avg(`col_int_key_signed` and `col_int_key_unsigned` <=> `col_int_undef_unsigned`), min(distinct `col_varbinary(20)_key_signed`)) or count(*) is null"] 
[err="runtime error: invalid memory address or nil pointer dereference"]
 [stack="goroutine 36029 [running]:
github.com/pingcap/tidb/server.(*clientConn).Run.func1()
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1029 +0x8f
panic({0x3432f40, 0x55c8470})
    /usr/local/go/src/runtime/panic.go:838 +0x207
github.com/pingcap/tidb/planner/core.(*copTask).count(0xc002396d80?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/task.go:109 +0x22    
github.com/pingcap/tidb/planner/core.(*PhysicalIndexScan).addPushedDownSelection(0xc003dda000, 0xc002396d80, 0xc003969900, 0xc0025a59e0, 0x0?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:1472 +0x68a
github.com/pingcap/tidb/planner/core.(*DataSource).convertToIndexScan(0xc003969900, 0xc003d838f0, 0xc004d16940, 0x0?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:1351 +0x6b5
github.com/pingcap/tidb/planner/core.(*DataSource).findBestTask(0xc003969900, 0xc003d838f0, 0x5667ac0, 0x25fe989?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:945 +0x114e
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).enumeratePhysicalPlans4Task(0xc0037ee6b0, {0xc004006430, 0x1, 0x18?}, 0xc003d83880, 0x0, 0x5667ac0, 0x12798e5?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:223 +0x625
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc0037ee6b0, 0xc003d83810, 0x5667ac0, 0x25fe989?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:401 +0x3ca
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).enumeratePhysicalPlans4Task(0xc0037ee7a0, {0xc004006410, 0x1, 0x18?}, 0xc003d837a0, 0x0, 0xc0037f7088, 0x12798e5?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:223 +0x625
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc0037ee7a0, 0xc003d83730, 0xc0037f7088, 0x0?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:401 +0x3ca
github.com/pingcap/tidb/planner/core.physicalOptimize({0x3dde7f8, 0xc0037ee780}, 0xc0037f7088)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:497 +0x244
github.com/pingcap/tidb/planner/core.DoOptimize({0x3db94d0, 0xc0043f8c30}, {0x3e0c638, 0xc001cb4fc0}, 0xc003d82070?, {0x3dde7f8, 0xc0037ee780})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:285 +0x169
github.com/pingcap/tidb/planner.optimize({0x3db94d0, 0xc0043f8c30}, {0x3e0c638, 0xc001cb4fc0}, {0x3dc6508, 0xc0025a4fc0?}, {0x3dd83d0, 0xc00261f500})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:392 +0x81e
github.com/pingcap/tidb/planner.Optimize({0x3db94d0, 0xc0043f8c30}, {0x3e0c638, 0xc001cb4fc0}, {0x3dc6508, 0xc0025a4fc0}, {0x3dd83d0, 0xc00261f500})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:222 +0xc45
github.com/pingcap/tidb/executor.(*Compiler).Compile(0xc000adad48, {0x3db94d0, 0xc0043f8c30}, {0x3dca750, 0xc0025a4fc0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:77 +0x485
github.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc001cb4fc0, {0x3db94d0, 0xc0043f8c30}, {0x3dca750, 0xc0025a4fc0?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:1852 +0x62b
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc00299b050, {0x3db94d0?, 0xc0043f8c30?}, {0x3dca750?, 0xc0025a4fc0?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/driver_tidb.go:224 +0x44
github.com/pingcap/tidb/server.(*clientConn).handleStmt(0xc002051a40, {0x3db9428, 0xc001b80b40}, {0x3dca750, 0xc0025a4fc0}, {0x5d2e5b0, 0x0, 0x0}, 0x1)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pin"]

4. What is your TiDB version? (Required)

Release Version: v6.1.0-nightly
Edition: Community
Git Commit Hash: d07b66e
Git Branch: heads/refs/tags/v6.1.0-nightly
UTC Build Time: 2022-04-12 23:03:50
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

@River2000i River2000i added the type/bug The issue is confirmed as a bug. label Apr 13, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. 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.0 labels Apr 13, 2022
@seiya-annie seiya-annie removed may-affects-4.0 This bug maybe affects 4.0.x versions. 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-5.0 This bug maybe affects 5.0.x versions. labels Apr 13, 2022
@seiya-annie
Copy link

only reproduced on v6.0.0

@zanmato1984 zanmato1984 added sig/planner SIG: Planner and removed sig/execution SIG execution labels Apr 13, 2022
@qw4990 qw4990 self-assigned this Apr 18, 2022
@VelocityLight VelocityLight added the affects-6.1 This bug affects the 6.1.x(LTS) versions. label May 20, 2022
@windtalker
Copy link
Contributor

Can't reproduce in master, so remove affects-6.1 label.

@windtalker windtalker removed the affects-6.1 This bug affects the 6.1.x(LTS) versions. label May 23, 2022
@ChenPeng2013
Copy link
Contributor

reproduce in release-6.1

MySQL [test]> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                            |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.1.0
Edition: Community
Git Commit Hash: 1a89decdb192cbdce6a7b0020d71128bc964d30f
Git Branch: release-6.1
UTC Build Time: 2022-06-20 01:03:08
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

MySQL [test]> drop table if exists t1;
Query OK, 0 rows affected (0.02 sec)

MySQL [test]> create table t1(a int AUTO_INCREMENT primary key, b int, c varbinary(20), index(b), index(c));
Query OK, 0 rows affected (0.01 sec)

MySQL [test]> select count(*) from t1 group by a having ifnull(avg(`b`), min(`c`));
ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference

@ChenPeng2013 ChenPeng2013 added the affects-6.1 This bug affects the 6.1.x(LTS) versions. label Jun 20, 2022
@VelocityLight VelocityLight added the affects-6.5 This bug affects the 6.5.x(LTS) versions. label Dec 2, 2022
@VelocityLight VelocityLight added the affects-7.1 This bug affects the 7.1.x(LTS) versions. label Apr 20, 2023
@ti-chi-bot ti-chi-bot added the affects-7.5 This bug affects the 7.5.x(LTS) versions. label Oct 23, 2023
@qw4990
Copy link
Contributor

qw4990 commented Nov 8, 2023

It has already been fixed by #38802

@qw4990 qw4990 closed this as completed Nov 8, 2023
@ti-chi-bot ti-chi-bot removed affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. labels Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

9 participants