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

ASAN : SIGSEGV in Sp_handler::db_find_routine | Sp_handler::db_find_and_cache_routine

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 13.1
    • N/A
    • Stored routines
    • None
    • Not for Release Notes
    • Q3/2026 Server Maintenance

    Description

      MTR Test

      SET sql_mode=ORACLE;
      CREATE DATABASE db1;
      USE db1;
      DELIMITER $$;
      CREATE PACKAGE a_pkg AS
        TYPE arec IS RECORD (x INT, y VARCHAR(10));
      END;
      $$
      CREATE PACKAGE b_pkg AS
        TYPE brec IS RECORD (p INT, q VARCHAR(10));
        TYPE bcur IS REF CURSOR RETURN a_pkg.arec;
      END;
      $$
      CREATE OR REPLACE PACKAGE a_pkg AS
        TYPE arec IS RECORD (x INT, y VARCHAR(10));
        TYPE acur IS REF CURSOR RETURN b_pkg.brec;
      END;
      $$
      CREATE PROCEDURE p_cycle AS
        c a_pkg.acur;
      BEGIN
        NULL;
      END;
      $$
      DELIMITER ;$$
      

      Leads to

      MDEV-39587 CS 13.1.0 61cd5a8ead368bd1d273cdc52300616d57c5ded1 (Optimized, UBASAN, Clang 18.1.3-11) Build 17/07/2026

      Core was generated by `/test/mtest/MDEV-39587/UBASAN_MD170726-mariadb-13.1.0-linux-x86_64-opt/bin/mari'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x000061a4c2e8453b in Sp_handler::db_find_routine (this=<optimized out>, thd=<optimized out>, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:698
       
      [Current thread is 1 (LWP 2918347)]
      (gdb) bt
      #0  0x000061a4c2e8453b in Sp_handler::db_find_routine (this=<optimized out>, thd=<optimized out>, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:698
      #1  0x000061a4c2e87838 in Sp_handler::db_find_and_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebb8b8c0, sp=0x70b5ebb8b8a0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:800
      #2  0x000061a4c2e9d97a in Sp_handler::sp_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=<optimized out>, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:3010
      #3  0x000061a4c2e99cb8 in Sp_handler::sp_cache_routine_reentrant (this=<optimized out>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebb8b8c0, sp=sp@entry=0x70b5ebb8b8a0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2524
      #4  0x000061a4c2e9a018 in Sp_handler::sp_cache_routine_reentrant_suppress_errors (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2540
      #5  0x000061a4c2e9a2a7 in Sp_handler::find_package_spec (thd=<optimized out>, db=<optimized out>, package=@0x70b5ec56f510: {str = 0x52500053dbf8 "a_pkg", length = 5})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2560
      #6  0x000061a4c2edcd3e in sp_head::get_typedef_package_spec_or_error (this=0x52500053c1f0, thd=<optimized out>, tdef=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp_head.cc:4480
      #7  0x000061a4c3439759 in LEX::declare_type_ref_cursor_return_typedef (this=<optimized out>, thd=0x52c0001b0220, type_name=<optimized out>, db=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_lex.cc:13396
      #8  0x000061a4c322b06c in ORAparse (thd=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_yacc.yy:20908
      #9  0x000061a4c34f2650 in parse_sql (thd=thd@entry=0x52c0001b0220, parser_state=parser_state@entry=0x70b5ebdfcc20, creation_ctx=creation_ctx@entry=0x52500057ee70, do_pfs_digest=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_parse.cc:10372
      #10 0x000061a4c2e883fe in sp_compile (thd=0x52c0001b0220, defstr=<optimized out>, sql_mode=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:909
      #11 0x000061a4c2e861d3 in Sp_handler::db_load_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>, sql_mode=<optimized out>, sql_path=<optimized out>, params=<optimized out>, returns=<optimized out>, body=<optimized out>, chistics=<optimized out>, definer=<optimized out>, created=<optimized out>, modified=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:1036
      #12 0x000061a4c2e85456 in Sp_handler::db_find_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:776
      #13 0x000061a4c2e87838 in Sp_handler::db_find_and_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebb88bc0, sp=0x70b5ebb88ba0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:800
      #14 0x000061a4c2e9d97a in Sp_handler::sp_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=<optimized out>, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:3010
      #15 0x000061a4c2e99cb8 in Sp_handler::sp_cache_routine_reentrant (this=<optimized out>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebb88bc0, sp=sp@entry=0x70b5ebb88ba0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2524
      #16 0x000061a4c2e9a018 in Sp_handler::sp_cache_routine_reentrant_suppress_errors (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2540
      #17 0x000061a4c2e9a2a7 in Sp_handler::find_package_spec (thd=<optimized out>, db=<optimized out>, package=@0x70b5ec576030: {str = 0x52500057ebf8 "b_pkg", length = 5})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2560
      #18 0x000061a4c2edcd3e in sp_head::get_typedef_package_spec_or_error (this=0x52500057d1f0, thd=<optimized out>, tdef=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp_head.cc:4480
      #19 0x000061a4c3439759 in LEX::declare_type_ref_cursor_return_typedef (this=<optimized out>, thd=0x52c0001b0220, type_name=<optimized out>, db=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_lex.cc:13396
      #20 0x000061a4c322b06c in ORAparse (thd=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_yacc.yy:20908
      #21 0x000061a4c34f2650 in parse_sql (thd=thd@entry=0x52c0001b0220, parser_state=parser_state@entry=0x70b5ebdf4820, creation_ctx=creation_ctx@entry=0x52500057c670, do_pfs_digest=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_parse.cc:10372
      #22 0x000061a4c2e883fe in sp_compile (thd=0x52c0001b0220, defstr=<optimized out>, sql_mode=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:909
      #23 0x000061a4c2e861d3 in Sp_handler::db_load_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>, sql_mode=<optimized out>, sql_path=<optimized out>, params=<optimized out>, returns=<optimized out>, body=<optimized out>, chistics=<optimized out>, definer=<optimized out>, created=<optimized out>, modified=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:1036
      #24 0x000061a4c2e85456 in Sp_handler::db_find_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:776
      #25 0x000061a4c2e87838 in Sp_handler::db_find_and_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebb85dc0, sp=0x70b5ebb85da0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:800
      #26 0x000061a4c2e9d97a in Sp_handler::sp_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=<optimized out>, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:3010
      #27 0x000061a4c2e99cb8 in Sp_handler::sp_cache_routine_reentrant (this=<optimized out>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebb85dc0, sp=sp@entry=0x70b5ebb85da0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2524
      #28 0x000061a4c2e9a018 in Sp_handler::sp_cache_routine_reentrant_suppress_errors (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2540
      #29 0x000061a4c2e9a2a7 in Sp_handler::find_package_spec (thd=<optimized out>, db=<optimized out>, package=@0x70b5ec57cb50: {str = 0x52500057c3f8 "a_pkg", length = 5})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2560
      #30 0x000061a4c2edcd3e in sp_head::get_typedef_package_spec_or_error (this=0x52500057a9f0, thd=<optimized out>, tdef=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp_head.cc:4480
      #31 0x000061a4c3439759 in LEX::declare_type_ref_cursor_return_typedef (this=<optimized out>, thd=0x52c0001b0220, type_name=<optimized out>, db=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_lex.cc:13396
      #32 0x000061a4c322b06c in ORAparse (thd=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_yacc.yy:20908
      [..]
      ]#216 0x000061a4c2e85456 in Sp_handler::db_find_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:776
      #217 0x000061a4c2e87838 in Sp_handler::db_find_and_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebc58ac0, sp=0x70b5ebc58aa0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:800
      #218 0x000061a4c2e9d97a in Sp_handler::sp_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=<optimized out>, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:3010
      #219 0x000061a4c2e99cb8 in Sp_handler::sp_cache_routine_reentrant (this=<optimized out>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebc58ac0, sp=sp@entry=0x70b5ebc58aa0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2524
      #220 0x000061a4c2e9a018 in Sp_handler::sp_cache_routine_reentrant_suppress_errors (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2540
      #221 0x000061a4c2e9a2a7 in Sp_handler::find_package_spec (thd=<optimized out>, db=<optimized out>, package=@0x70b5ec5e7d50: {str = 0x525000597bf8 "a_pkg", length = 5})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2560
      #222 0x000061a4c2edcd3e in sp_head::get_typedef_package_spec_or_error (this=0x5250005961f0, thd=<optimized out>, tdef=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp_head.cc:4480
      #223 0x000061a4c3439759 in LEX::declare_type_ref_cursor_return_typedef (this=<optimized out>, thd=0x52c0001b0220, type_name=<optimized out>, db=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_lex.cc:13396
      #224 0x000061a4c322b06c in ORAparse (thd=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_yacc.yy:20908
      #225 0x000061a4c34f2650 in parse_sql (thd=thd@entry=0x52c0001b0220, parser_state=parser_state@entry=0x70b5ebd74620, creation_ctx=creation_ctx@entry=0x525000595670, do_pfs_digest=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_parse.cc:10372
      #226 0x000061a4c2e883fe in sp_compile (thd=0x52c0001b0220, defstr=<optimized out>, sql_mode=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:909
      #227 0x000061a4c2e861d3 in Sp_handler::db_load_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>, sql_mode=<optimized out>, sql_path=<optimized out>, params=<optimized out>, returns=<optimized out>, body=<optimized out>, chistics=<optimized out>, definer=<optimized out>, created=<optimized out>, modified=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:1036
      #228 0x000061a4c2e85456 in Sp_handler::db_find_routine (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:776
      #229 0x000061a4c2e87838 in Sp_handler::db_find_and_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebc55dc0, sp=0x70b5ebc55da0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:800
      #230 0x000061a4c2e9d97a in Sp_handler::sp_cache_routine (this=0x61a4c5dadc40 <sp_handler_package_spec>, thd=<optimized out>, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:3010
      #231 0x000061a4c2e99cb8 in Sp_handler::sp_cache_routine_reentrant (this=<optimized out>, thd=thd@entry=0x52c0001b0220, name=name@entry=0x70b5ebc55dc0, sp=sp@entry=0x70b5ebc55da0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2524
      #232 0x000061a4c2e9a018 in Sp_handler::sp_cache_routine_reentrant_suppress_errors (this=<optimized out>, thd=0x52c0001b0220, name=<optimized out>, sp=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2540
      #233 0x000061a4c2e9a2a7 in Sp_handler::find_package_spec (thd=<optimized out>, db=<optimized out>, package=@0x70b5ec5ee870: {str = 0x5250005953f8 "b_pkg", length = 5})at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:2560
      #234 0x000061a4c2edcd3e in sp_head::get_typedef_package_spec_or_error (this=0x5250005939f0, thd=<optimized out>, tdef=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp_head.cc:4480
      #235 0x000061a4c3439759 in LEX::declare_type_ref_cursor_return_typedef (this=<optimized out>, thd=0x52c0001b0220, type_name=<optimized out>, db=<optimized out>, package=<optimized out>, type=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_lex.cc:13396
      #236 0x000061a4c322b06c in ORAparse (thd=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_yacc.yy:20908
      #237 0x000061a4c34f2650 in parse_sql (thd=thd@entry=0x52c0001b0220, parser_state=parser_state@entry=0x70b5ebd6d220, creation_ctx=creation_ctx@entry=0x525000592e70, do_pfs_digest=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sql_parse.cc:10372
      #238 0x000061a4c2e883fe in sp_compile (thd=0x52c0001b0220, defstr=<optimized out>, sql_mode=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt_san/sql/sp.cc:909
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 4.7h Original Estimate - 4.7h
                  4.7h
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 6.5h
                  6.5h

                  Git Integration

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