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

SIGSEGV in Item_field::used_tables on a plugin aggregate with FILTER

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.2
    • 13.2
    • Plugins
    • None
    • Not for Release Notes
    • Q4/2026 Server Maintenance

    Description

      INSTALL SONAME 'func_test';
      CREATE TABLE t (id INT PRIMARY KEY, g INT, v INT);
      INSERT INTO t VALUES (1,1,10),(2,1,20),(3,2,30),(4,2,NULL),(5,3,50);
      SELECT test_plugin_count(v) FILTER (WHERE v > 15) FROM t;
      

      Leads to

      MDEV-40672 CS 13.2.0 bedb5a2b25e534ed2d344d2f724115a6f5b07b7b (Optimized, Clang 18.1.3-11) Build 29/09/2026

      Core was generated by `/test/mtest/MDEV-40672/MD290926-mariadb-13.2.0-linux-x86_64-opt/bin/mariadbd --'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x0000578d39a714fb in Item_field::used_tables (this=0x75ebf0018400)at /test/mtest/MDEV-40672/13.1_opt/sql/item.cc:3833
       
      [Current thread is 1 (LWP 697267)]
      (gdb) bt
      #0  0x0000578d39a714fb in Item_field::used_tables (this=0x75ebf0018400)at /test/mtest/MDEV-40672/13.1_opt/sql/item.cc:3833
      #1  0x0000578d396f58ec in Used_tables_and_const_cache::used_tables_and_const_cache_join (item=0x75ebf0018400, this=<optimized out>)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:6021
      #2  Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join (item=0x75ebf0018400, this=<optimized out>)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:6027
      #3  Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join (this=0x75ebf0018678, argv=0x75ebf0018660, argc=<optimized out>)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:6038
      #4  Item_func::update_used_tables (this=0x75ebf00185d0)at /test/mtest/MDEV-40672/13.1_opt/sql/item_func.h:217
      #5  0x0000578d39b3b612 in Item_sum::update_used_tables (this=0x75ebf0018850)at /test/mtest/MDEV-40672/13.1_opt/sql/item_sum.cc:621
      #6  0x0000578d39b3a974 in Item_sum::check_sum_func (this=this@entry=0x75ebf0018850, thd=thd@entry=0x75ebf0000c70, ref=ref@entry=0x75ebf0018998)at /test/mtest/MDEV-40672/13.1_opt/sql/item_sum.cc:353
      #7  0x0000578d39b3b27a in Item_sum_plugin::fix_fields (this=0x75ebf0018850, thd=0x75ebf0000c70, ref=0x75ebf0018998)at /test/mtest/MDEV-40672/13.1_opt/sql/item_sum.cc:535
      #8  0x0000578d39767374 in Item::fix_fields_if_needed (this=0x75ebf0018850, thd=0x75ebf0000c70, ref=0x75ebf0018998)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:1153
      #9  Item::fix_fields_if_needed_for_scalar (this=0x75ebf0018850, thd=0x75ebf0000c70, ref=0x75ebf0018998)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:1162
      #10 setup_fields (thd=0x75ebf0000c70, ref_pointer_array={m_array = 0x75ebf001a370, m_size = 10}, fields=<optimized out>, column_usage=<optimized out>, sum_func_list=sum_func_list@entry=0x75ebf0019f40, pre_fix=0x75ebf0018028, allow_sum_func=<optimized out>, where=THD_WHERE::DEFAULT_WHERE)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_base.cc:8569
      #11 0x0000578d39812c35 in JOIN::prepare (this=this@entry=0x75ebf0019ba0, tables_init=tables_init@entry=0x75ebf0018a80, conds_init=conds_init@entry=0x0, og_num=og_num@entry=0, order_init=order_init@entry=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x75ebf0017d40, unit_arg=0x75ebf0005230)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_select.cc:1613
      #12 0x0000578d3980f041 in mysql_select (thd=thd@entry=0x75ebf0000c70, tables=0x75ebf0018a80, fields=@0x75ebf0017ff8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x75ebf0018990, last = 0x75ebf0018990, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x75ebf0019b70, unit=0x75ebf0005230, select_lex=0x75ebf0017d40)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_select.cc:5425
      #13 0x0000578d3980ee70 in handle_select (thd=thd@entry=0x75ebf0000c70, lex=lex@entry=0x75ebf0005150, result=result@entry=0x75ebf0019b70, setup_tables_done_option=setup_tables_done_option@entry=0)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_select.cc:651
      #14 0x0000578d397da405 in execute_sqlcom_select (thd=thd@entry=0x75ebf0000c70, all_tables=0x75ebf0018a80)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:6266
      #15 0x0000578d397d5b0b in mysql_execute_command (thd=thd@entry=0x75ebf0000c70, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:4038
      #16 0x0000578d397d0eb2 in mysql_parse (thd=thd@entry=0x75ebf0000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7decd92b1580)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:8005
      #17 0x0000578d397cf468 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x75ebf0000c70, packet=packet@entry=0x75ebf0008ea1 "SELECT test_plugin_count(v) FILTER (WHERE v > 15) FROM t", packet_length=packet_length@entry=56, blocking=true)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:1903
      #18 0x0000578d397d1331 in do_command (thd=thd@entry=0x75ebf0000c70, blocking=true) at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:1437
      #19 0x0000578d398fde5d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x578d50124ba0, put_in_cache=true)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_connect.cc:1514
      #20 0x0000578d398fdc92 in handle_one_connection (arg=arg@entry=0x578d50124ba0)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_connect.cc:1426
      #21 0x0000578d39cabb53 in pfs_spawn_thread (arg=0x578d50145590)at /test/mtest/MDEV-40672/13.1_opt/storage/perfschema/pfs.cc:2198
      #22 0x00007ded06c9cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #23 0x00007ded06d29ecc in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Reduced test case (with empty table)

      INSTALL SONAME 'func_test';
      CREATE TABLE t (c INT);
      SELECT test_plugin_count(1) FILTER (WHERE c) FROM t;
      

      Leads to

      MDEV-40672 CS 13.2.0 bedb5a2b25e534ed2d344d2f724115a6f5b07b7b (Optimized, Clang 18.1.3-11) Build 29/09/2026

      Core was generated by `/test/mtest/MDEV-40672/MD290926-mariadb-13.2.0-linux-x86_64-opt/bin/mariadbd --'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00005eb37e7424fb in Item_field::used_tables (this=0x7523ac018370)at /test/mtest/MDEV-40672/13.1_opt/sql/item.cc:3833
       
      [Current thread is 1 (LWP 970577)]
      (gdb) bt
      #0  0x00005eb37e7424fb in Item_field::used_tables (this=0x7523ac018370)at /test/mtest/MDEV-40672/13.1_opt/sql/item.cc:3833
      #1  0x00005eb37e80c622 in Item_sum::update_used_tables (this=0x7523ac0184e0)at /test/mtest/MDEV-40672/13.1_opt/sql/item_sum.cc:622
      #2  0x00005eb37e80b974 in Item_sum::check_sum_func (this=this@entry=0x7523ac0184e0, thd=thd@entry=0x7523ac000c70, ref=ref@entry=0x7523ac018628)at /test/mtest/MDEV-40672/13.1_opt/sql/item_sum.cc:353
      #3  0x00005eb37e80c27a in Item_sum_plugin::fix_fields (this=0x7523ac0184e0, thd=0x7523ac000c70, ref=0x7523ac018628)at /test/mtest/MDEV-40672/13.1_opt/sql/item_sum.cc:535
      #4  0x00005eb37e438374 in Item::fix_fields_if_needed (this=0x7523ac0184e0, thd=0x7523ac000c70, ref=0x7523ac018628)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:1153
      #5  Item::fix_fields_if_needed_for_scalar (this=0x7523ac0184e0, thd=0x7523ac000c70, ref=0x7523ac018628)at /test/mtest/MDEV-40672/13.1_opt/sql/item.h:1162
      #6  setup_fields (thd=0x7523ac000c70, ref_pointer_array={m_array = 0x7523ac01a080, m_size = 7}, fields=<optimized out>, column_usage=<optimized out>, sum_func_list=sum_func_list@entry=0x7523ac019c50, pre_fix=0x7523ac018028, allow_sum_func=<optimized out>, where=THD_WHERE::DEFAULT_WHERE)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_base.cc:8569
      #7  0x00005eb37e4e3c35 in JOIN::prepare (this=this@entry=0x7523ac0198b0, tables_init=tables_init@entry=0x7523ac018700, conds_init=conds_init@entry=0x0, og_num=og_num@entry=0, order_init=order_init@entry=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7523ac017d40, unit_arg=0x7523ac005230)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_select.cc:1613
      #8  0x00005eb37e4e0041 in mysql_select (thd=thd@entry=0x7523ac000c70, tables=0x7523ac018700, fields=@0x7523ac017ff8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7523ac018620, last = 0x7523ac018620, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x7523ac019880, unit=0x7523ac005230, select_lex=0x7523ac017d40)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_select.cc:5425
      #9  0x00005eb37e4dfe70 in handle_select (thd=thd@entry=0x7523ac000c70, lex=lex@entry=0x7523ac005150, result=result@entry=0x7523ac019880, setup_tables_done_option=setup_tables_done_option@entry=0)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_select.cc:651
      #10 0x00005eb37e4ab405 in execute_sqlcom_select (thd=thd@entry=0x7523ac000c70, all_tables=0x7523ac018700)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:6266
      #11 0x00005eb37e4a6b0b in mysql_execute_command (thd=thd@entry=0x7523ac000c70, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:4038
      #12 0x00005eb37e4a1eb2 in mysql_parse (thd=thd@entry=0x7523ac000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7d24c02f3580)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:8005
      #13 0x00005eb37e4a0468 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7523ac000c70, packet=packet@entry=0x7523ac008ea1 "SELECT test_plugin_count(1) FILTER (WHERE c) FROM t", packet_length=packet_length@entry=51, blocking=true)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:1903
      #14 0x00005eb37e4a2331 in do_command (thd=thd@entry=0x7523ac000c70, blocking=true) at /test/mtest/MDEV-40672/13.1_opt/sql/sql_parse.cc:1437
      #15 0x00005eb37e5cee5d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5eb3c0982bd0, put_in_cache=true)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_connect.cc:1514
      #16 0x00005eb37e5cec92 in handle_one_connection (arg=arg@entry=0x5eb3c0982bd0)at /test/mtest/MDEV-40672/13.1_opt/sql/sql_connect.cc:1426
      #17 0x00005eb37e97cb53 in pfs_spawn_thread (arg=0x5eb3c09a3510)at /test/mtest/MDEV-40672/13.1_opt/storage/perfschema/pfs.cc:2198
      #18 0x00007d24c469cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #19 0x00007d24c4729ecc in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              drrtuy Roman
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 37m Original Estimate - 37m
                  37m
                  Remaining:
                  Time Spent - 0.5h Remaining Estimate - 37m
                  37m
                  Logged:
                  Time Spent - 0.5h Remaining Estimate - 37m
                  0.5h

                  Git Integration

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