Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17505

Crash in Dep_analysis_context::dbug_print_deps when running under --debug



    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.3.11
    • N/A
    • Optimizer
    • None


      The following sequence of commands (taken from select.test) will crash the server when the server is started with --debug.

      # Bug#40953 SELECT query throws "ERROR 1062 (23000): Duplicate entry..." error
      CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',
                       f2 int(11) NOT NULL default '0',
                       f3 bigint(20) NOT NULL default '0',
                       f4 varchar(255) NOT NULL default '',
                       PRIMARY KEY (f1),
                       KEY key1 (f4),
                       KEY key2 (f2));
      CREATE TABLE t2 (f1 int(11) NOT NULL default '0',
                       f2 enum('A1','A2','A3') NOT NULL default 'A1',
                       f3 int(11) NOT NULL default '0',
                       PRIMARY KEY (f1),
                       KEY key1 (f3));
      CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0',
                       f2 datetime NOT NULL default '1980-01-01 00:00:00',
                       PRIMARY KEY (f1));
      insert into t1 values (1, 1, 1, 'abc');
      insert into t1 values (2, 1, 2, 'def');
      insert into t1 values (3, 1, 2, 'def');
      insert into t2 values (1, 'A1', 1);
      insert into t3 values (1, '1980-01-01');
      SELECT a.f3, cr.f4, count(*) count
      FROM t2 a
      STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1
      (t1 cr2
        JOIN t3 ae2 ON cr2.f3 = ae2.f1
      ) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND
      cr.f4 = cr2.f4
      GROUP BY a.f3, cr.f4;

      Stack trace:

      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      57      ../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
      [Current thread is 1 (Thread 0x7f1d94e4f700 (LWP 30443))]
      #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x0000557de7228f44 in my_write_core (sig=11) at /home/psergey/dev-git/10.3-clean/mysys/stacktrace.c:481
      #2  0x0000557de6a73fed in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.3-clean/sql/signal_handler.cc:305
      #3  <signal handler called>
      #4  0x0000557de694caa0 in Dep_analysis_context::dbug_print_deps (this=0x7f1d94e4cf30) at /home/psergey/dev-git/10.3-clean/sql/opt_table_elimination.cc:1841
      #5  0x0000557de694a817 in check_func_dependency (join=0x7f1d8401a700, dep_tables=12, it=0x7f1d94e4d1f0, oj_tbl=0x0, cond=0x7f1d8401ae40) at /home/psergey/dev-git/10.3-clean/sql/opt_table_elimination.cc:863
      #6  0x0000557de694a48b in eliminate_tables_for_list (join=0x7f1d8401a700, join_list=0x7f1d84018d40, list_tables=12, on_expr=0x7f1d8401ae40, tables_used_elsewhere=3) at /home/psergey/dev-git/10.3-clean/sql/opt_table_elimination.cc:773
      #7  0x0000557de694a2d2 in eliminate_tables_for_list (join=0x7f1d8401a700, join_list=0x7f1d84005520, list_tables=15, on_expr=0x0, tables_used_elsewhere=3) at /home/psergey/dev-git/10.3-clean/sql/opt_table_elimination.cc:733
      #8  0x0000557de694a1ac in eliminate_tables (join=0x7f1d8401a700) at /home/psergey/dev-git/10.3-clean/sql/opt_table_elimination.cc:671
      #9  0x0000557de67d5ec5 in make_join_statistics (join=0x7f1d8401a700, tables_list=..., keyuse_array=0x7f1d8401a9f0) at /home/psergey/dev-git/10.3-clean/sql/sql_select.cc:4547
      #10 0x0000557de67ccbb9 in JOIN::optimize_inner (this=0x7f1d8401a700) at /home/psergey/dev-git/10.3-clean/sql/sql_select.cc:1895
      #11 0x0000557de67cb20f in JOIN::optimize (this=0x7f1d8401a700) at /home/psergey/dev-git/10.3-clean/sql/sql_select.cc:1448
      #12 0x0000557de67d4d70 in mysql_select (thd=0x7f1d84000d60, tables=0x7f1d840156f0, wild_num=0, fields=..., conds=0x0, og_num=2, order=0x0, group=0x7f1d8401a3d8, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f1d8401a6d8, unit=0x7f1d84004c10, select_lex=0x7f1d84005380) at /home/psergey/dev-git/10.3-clean/sql/sql_select.cc:4220
      #13 0x0000557de67c6d55 in handle_select (thd=0x7f1d84000d60, lex=0x7f1d84004b48, result=0x7f1d8401a6d8, setup_tables_done_option=0) at /home/psergey/dev-git/10.3-clean/sql/sql_select.cc:370


        Issue Links



              Unassigned Unassigned
              psergei Sergei Petrunia
              0 Vote for this issue
              2 Start watching this issue



                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.