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

SIGSEGV in set_field_to_null_with_conversions on SELECT (on optimized builds)

    XMLWordPrintable

Details

    Description

      USE test;
      CREATE TABLE t (i INT, j INT, KEY(i)) ENGINE=InnoDB;
      SELECT FIRST_VALUE(j) OVER (ORDER BY 0 + (SELECT FIRST_VALUE(upper.j) OVER (ORDER BY upper.j) FROM t LIMIT 1)) FROM t AS upper;
      

      Leads to:

      10.5.4 8569dac1ec9f6853a0b2f3ea9bcbda67644ead24

      Core was generated by `/test/MD260520-mariadb-10.5.4-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x14c4294d1700 (LWP 3556701))]
      (gdb) bt
      (gdb) (gdb) #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x000055dfe7fb8337 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:518
      #2  0x000055dfe797a3ca in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  set_field_to_null_with_conversions (field=0x0, no_conversions=true) at /test/10.5_opt/sql/field_conv.cc:205
      #5  0x000055dfe79905e6 in Item::save_in_field (this=0x14c406847ee0, field=0x0, no_conversions=<optimized out>) at /test/10.5_opt/sql/item.cc:6605
      #6  0x000055dfe77d5913 in Item_result_field::save_in_result_field (no_conversions=true, this=<optimized out>) at /test/10.5_opt/sql/item.h:3255
      #7  copy_sum_funcs (end_ptr=0x14c40684be68, func_ptr=0x14c40684be60) at /test/10.5_opt/sql/sql_select.cc:25650
      #8  end_write_group (join=0x14c40684a948, join_tab=0x14c4068c93d8, end_of_records=<optimized out>) at /test/10.5_opt/sql/sql_select.cc:22272
      #9  0x000055dfe77da87b in AGGR_OP::end_send (this=0x14c4068cc3c8) at /test/10.5_opt/sql/sql_select.cc:28855
      #10 0x000055dfe77daaee in sub_select_postjoin_aggr (join=0x14c40684a948, join_tab=0x14c4068c93d8, end_of_records=<optimized out>) at /test/10.5_opt/sql/sql_select.cc:20325
      #11 0x000055dfe77e226d in do_select (procedure=<optimized out>, join=0x14c40684a948) at /test/10.5_opt/sql/sql_select.cc:20151
      #12 JOIN::exec_inner (this=this@entry=0x14c40684a948) at /test/10.5_opt/sql/sql_select.cc:4464
      #13 0x000055dfe77e2677 in JOIN::exec (this=this@entry=0x14c40684a948) at /test/10.5_opt/sql/sql_select.cc:4245
      #14 0x000055dfe77e09c2 in mysql_select (thd=thd@entry=0x14c406812018, tables=0x14c4068498c0, fields=@0x14c4068472e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14c406849800, last = 0x14c406849800, elements = 1}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14c40684a920, unit=0x14c406815e70, select_lex=0x14c406847190) at /test/10.5_opt/sql/sql_select.cc:4669
      #15 0x000055dfe77e1381 in handle_select (thd=thd@entry=0x14c406812018, lex=lex@entry=0x14c406815da8, result=result@entry=0x14c40684a920, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_opt/sql/sql_select.cc:417
      #16 0x000055dfe7787e91 in execute_sqlcom_select (thd=thd@entry=0x14c406812018, all_tables=0x14c4068498c0) at /test/10.5_opt/sql/sql_parse.cc:6207
      #17 0x000055dfe7783db2 in mysql_execute_command (thd=thd@entry=0x14c406812018) at /test/10.5_opt/sql/sql_parse.cc:3939
      #18 0x000055dfe778afac in mysql_parse (thd=0x14c406812018, rawbuf=<optimized out>, length=126, parser_state=0x14c4294d04b0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7991
      #19 0x000055dfe77802b5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14c406812018, packet=packet@entry=0x14c40683a019 "", packet_length=packet_length@entry=126, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1874
      #20 0x000055dfe777e6a4 in do_command (thd=0x14c406812018) at /test/10.5_opt/sql/sql_parse.cc:1355
      #21 0x000055dfe7873891 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14c428c329b8, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1411
      #22 0x000055dfe7873bf4 in handle_one_connection (arg=arg@entry=0x14c428c329b8) at /test/10.5_opt/sql/sql_connect.cc:1313
      #23 0x000055dfe7be006a in pfs_spawn_thread (arg=0x14c428c4b018) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
      #24 0x000014c42a4c86db in start_thread (arg=0x14c4294d1700) at pthread_create.c:463
      #25 0x000014c4298c688f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.2.33 (dbg), 10.2.33 (opt), 10.3.24 (dbg), 10.3.24 (opt), 10.4.14 (dbg), 10.4.14 (opt), 10.5.4 (dbg), 10.5.4 (opt)

      Bug confirmed not present in:
      MariaDB: 10.1.46 (dbg), 10.1.46 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)

      Issue is not reproducible on MyISAM, Aria or MEMORY. MyISAM example on 10.5.4 (opt):

      10.5.4 8569dac1ec9f6853a0b2f3ea9bcbda67644ead24

      10.5.4>SELECT FIRST_VALUE(j) OVER (ORDER BY 0 + (SELECT FIRST_VALUE(upper.j) OVER (ORDER BY upper.j) FROM t LIMIT 1)) FROM t AS upper;
      +---------------------------------------------------------------------------------------------------------+
      | FIRST_VALUE(j) OVER (ORDER BY 0 + (SELECT FIRST_VALUE(upper.j) OVER (ORDER BY upper.j) FROM t LIMIT 1)) |
      +---------------------------------------------------------------------------------------------------------+
      |                                                                                                    NULL |
      +---------------------------------------------------------------------------------------------------------+
      1 row in set (0.006 sec)
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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