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

SIGSEGV in LEX::sp_package_spec_check_cyclic_dependency | LEX::set_field_type_typedef_package_spec

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.1
    • 13.1
    • Stored routines
    • None
    • Not for Release Notes

    Description

      SET sql_mode=ORACLE;
       
      DELIMITER $$
      CREATE PACKAGE emp_pkg AS
        TYPE emp_rec IS RECORD (id INT);
        FUNCTION get_emp(p_id INT) RETURN emp_rec;
      END;
      $$
      CREATE PACKAGE BODY emp_pkg AS
        FUNCTION get_emp(p_id INT) RETURN emp_pkg.emp_rec AS
          v emp_pkg.emp_rec;
        BEGIN
          v.id := p_id;
          RETURN v;
        END;
      END;
      $$
      CREATE PROCEDURE show_emp AS
        v emp_pkg.emp_rec;
      BEGIN
        v := emp_pkg.get_emp(7);
        SELECT v.id AS id;
      END;
      $$
      DELIMITER ;
       
      CALL show_emp;
      

      Leads to

      MDEV-39587 CS 13.1.0 75d432e41947f082072e0011be33b99ddd8829fe (Optimized, Clang 18.1.3-11) Build 10/08/2026

      Core was generated by `/test/mtest/MDEV-39587/MD100826-mariadb-13.1.0-linux-x86_64-opt/bin/mariadbd --'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00007b818c1c8280 in ?? ()
      [Current thread is 1 (LWP 125770)]
      (gdb) bt
      #0  0x00007b818c1c8280 in ?? ()
      #1  0x00005ec5403359e9 in LEX::sp_package_spec_check_cyclic_dependency (this=this@entry=0x735ed805a7d0, thd=<optimized out>, db=@0x7b818c1c63d0: {<st_mysql_const_lex_string> = {str = 0x735ed805d690 "test", length = 4}, <Sql_alloc> = {<No data fields>}, <No data fields>}, name=@0x7b818c1c65c0: {<st_mysql_const_lex_string> = {str = 0x735ed805d830 "emp_pkg", length = 7}, <Sql_alloc> = {<No data fields>}, <No data fields>})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_lex.cc:13452
      #2  0x00005ec540336ec6 in LEX::set_field_type_typedef_package_spec (this=0x735ed805a7d0, res=0x7b818c1c7050, package=@0x7b818c1c65c0: {<st_mysql_const_lex_string> = {str = 0x735ed805d830 "emp_pkg", length = 7}, <Sql_alloc> = {<No data fields>}, <No data fields>}, type=@0x7b818c1c65f0: {<st_mysql_const_lex_string> = {str = 0x735ed805d870 "emp_rec", length = 7}, <Sql_alloc> = {<No data fields>}, <No data fields>})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_lex.cc:13850
      #3  0x00005ec54058b3a4 in ORAparse (thd=thd@entry=0x735ed8000c70)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_yacc.yy:6753
      #4  0x00005ec54035126f in parse_sql (thd=thd@entry=0x735ed8000c70, parser_state=parser_state@entry=0x7b818c1c7160, creation_ctx=creation_ctx@entry=0x735ed8056320, do_pfs_digest=false)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:10380
      #5  0x00005ec540294376 in sp_compile (thd=thd@entry=0x735ed8000c70, defstr=defstr@entry=0x7b818c1c7348, sql_mode=sql_mode@entry=8858427918, parent=0x0, creation_ctx=0x735ed8056320)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:909
      #6  0x00005ec540293fc7 in Sp_handler::db_load_routine (this=this@entry=0x5ec54162a8e8 <sp_handler_package_body>, thd=thd@entry=0x735ed8000c70, name=name@entry=0x7b818c1cb6a8, sphp=sphp@entry=0x7b818c1cb6a0, sql_mode=sql_mode@entry=8858427918, sql_path=@0x7b818c1cab98: {m_schemas = {{<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x735ed8013730 "CURRENT_SCHEMA", length = 0}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x0, length = 0}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>} <repeats 15 times>}, m_count = 1}, params=@0x7b818c1c9590: {str = 0x5ec540dac0af "", length = 0}, returns=@0x7b818c1c95f0: {str = 0x5ec540dac0af "", length = 0}, body=@0x7b818c1c95a0: {str = 0x735ed8056220 "AS\n  FUNCTION get_emp(p_id INT) RETURN emp_pkg.emp_rec AS\n    v emp_pkg.emp_rec;\n  BEGIN\n    v.id := p_id;\n    RETURN v;\n  END;\nEND", length = 131}, chistics=@0x7b818c1c95d0: {comment = {str = 0x5ec540dac0af "", length = 0}, suid = SP_IS_SUID, detistic = false, daccess = SP_CONTAINS_SQL, agg_type = NOT_AGGREGATE}, definer=@0x7b818c1c95b0: {user = {str = 0x735ed8056210 "root", length = 4}, host = {str = 0x735ed8056215 "localhost", length = 9}}, created=20260811064409, modified=20260811064409, parent=0x0, creation_ctx=0x735ed8056320)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:1036
      #7  0x00005ec540293ced in Sp_handler::db_find_routine (this=this@entry=0x5ec54162a8e8 <sp_handler_package_body>, thd=thd@entry=0x735ed8000c70, name=name@entry=0x7b818c1cb6a8, sphp=sphp@entry=0x7b818c1cb6a0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:776
      #8  0x00005ec540297c75 in Sp_handler::db_find_and_cache_routine (this=0x5ec54162a8e8 <sp_handler_package_body>, thd=0x735ed8000c70, name=0x7b818c1cb6a8, sp=0x7b818c1cb6a0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:800
      #9  Sp_handler::sp_cache_routine (this=0x5ec54162a8e8 <sp_handler_package_body>, thd=thd@entry=0x735ed8000c70, name=name@entry=0x7b818c1cb6a8, sp=sp@entry=0x7b818c1cb6a0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:3011
      #10 0x00005ec540297e4a in Sp_handler::sp_cache_package_routine (this=this@entry=0x5ec54162a900 <sp_handler_package_function>, thd=thd@entry=0x735ed8000c70, pkgname_cstr=@0x7b818c1cb720: {str = 0x7b818c1cb730 "emp_pkg", length = 7}, name=name@entry=0x7b818c1cb848, sp=sp@entry=0x7b818c1cba70)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:3094
      #11 0x00005ec540299017 in Sp_handler::sp_cache_package_routine (name=0x7b818c1cb848, this=<optimized out>, thd=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:3134
      #12 Sp_handler_package_function::sp_cache_routine (this=0x5ec54162a900 <sp_handler_package_function>, thd=0x735ed8000c70, name=0x7b818c1cb848, sp=0x7b818c1cba70)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.h:363
      #13 0x00005ec540297bbb in Sroutine_hash_entry::sp_cache_routine (this=0x735ed804b740, thd=0x735ed8000c70, sp=0x7b818c1cba70)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp.cc:2970
      #14 0x00005ec5402d73dd in open_and_process_routine (thd=0x735ed8000c70, rt=0x735ed804b740, prelocking_strategy=0x7b818c1cbba0, ot_ctx=0x7b818c1cbab0, need_prelocking=0x7b818c1cbaa7, prelocking_ctx=<optimized out>, has_prelocking_list=<optimized out>, routine_modifies_data=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_base.cc:3943
      #15 open_tables (thd=thd@entry=0x735ed8000c70, options=@0x735ed804ae2c: {m_options = DDL_options_st::OPT_NONE}, start=start@entry=0x7b818c1cbb60, counter=counter@entry=0x7b818c1cbb6c, flags=flags@entry=0, prelocking_strategy=prelocking_strategy@entry=0x7b818c1cbba0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_base.cc:4863
      #16 0x00005ec5402d89f4 in open_and_lock_tables (thd=0x7b818c1c8270, thd@entry=0x735ed8000c70, options=@0x7b818c1c63d0: {m_options = (DDL_options_st::OPT_OR_REPLACE | DDL_options_st::OPT_CREATE_SELECT | unknown: 0xd805d600)}, tables=0x0, derived=true, flags=3, flags@entry=0, prelocking_strategy=0x3, prelocking_strategy@entry=0x7b818c1cbba0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_base.cc:5812
      #17 0x00005ec5404ef5dd in open_and_lock_tables (thd=0x735ed8000c70, tables=0x0, derived=true, flags=0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_base.h:545
      #18 sp_instr::exec_open_and_lock_tables (this=0x735ed804c5e0, thd=0x735ed8000c70, tables=0x0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_instr.cc:704
      #19 sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x735ed804c618, thd=thd@entry=0x735ed8000c70, nextp=nextp@entry=0x7b818c1cbe84, open_tables=true, instr=instr@entry=0x735ed804c5e0, rerun_the_same_instr=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_instr.cc:416
      #20 0x00005ec5404efc36 in sp_lex_keeper::validate_lex_and_exec_core (this=0x735ed804c618, thd=0x735ed8000c70, nextp=0x7b818c1cbe84, open_tables=<optimized out>, instr=0x735ed804c5e0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_instr.cc:599
      #21 0x00005ec54029c1ca in sp_head::execute (this=this@entry=0x735ed8040460, thd=thd@entry=0x735ed8000c70, merge_da_on_success=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_head.cc:1333
      #22 0x00005ec54029dacb in sp_head::execute_procedure (this=0x735ed8040460, thd=0x735ed8000c70, args=0x735ed80061f8)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_head.cc:2370
      #23 0x00005ec5403480d3 in do_execute_sp (thd=thd@entry=0x735ed8000c70, sp=0x7b818c1c8270, sp@entry=0x735ed8040460)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:3084
      #24 0x00005ec540347d8d in Sql_cmd_call::execute (this=0x735ed8017e90, thd=0x735ed8000c70)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:3322
      #25 0x00005ec540349378 in mysql_execute_command (thd=thd@entry=0x735ed8000c70, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:5905
      #26 0x00005ec540344cc2 in mysql_parse (thd=thd@entry=0x735ed8000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7b818c1cd4c0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:7956
      #27 0x00005ec540343280 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x735ed8000c70, packet=packet@entry=0x735ed8008e01 "CALL show_emp", packet_length=packet_length@entry=13, blocking=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:1903
      #28 0x00005ec540345141 in do_command (thd=thd@entry=0x735ed8000c70, blocking=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:1437
      #29 0x00005ec54047015d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5ec56b360100, put_in_cache=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_connect.cc:1514
      #30 0x00005ec54046ff92 in handle_one_connection (arg=arg@entry=0x5ec56b360100)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_connect.cc:1426
      #31 0x00005ec540813e03 in pfs_spawn_thread (arg=0x5ec56b3806f0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/storage/perfschema/pfs.cc:2198
      #32 0x00007b818d89caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #33 0x00007b818d929c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Test case with procedure

      SET sql_mode=ORACLE;
       
      DELIMITER $$
      CREATE OR REPLACE PACKAGE emp_pkg AS
        TYPE emp_rec IS RECORD (id INT);
        PROCEDURE get_emp(p_id INT);
      END;
      $$
       
      CREATE OR REPLACE PACKAGE BODY emp_pkg AS
        PROCEDURE get_emp(p_id INT) AS
          v emp_pkg.emp_rec;
        BEGIN
          NULL;
        END;
      END;
      $$
       
      CREATE OR REPLACE PROCEDURE show_emp AS
      BEGIN
        emp_pkg.get_emp(7);
      END;
      $$
      DELIMITER ;
       
      CALL show_emp;
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.5h
                  0.5h

                  Git Integration

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