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

UBSAN: SIGSEGV in Sp_handler::db_load_routine | Sp_handler::db_find_routine

    XMLWordPrintable

Details

    • Can result in hang or crash
    • Q1/2026 Server Maintenance

    Description

      UBSAN builds crash when executing the following test case, but non-ubsan build shows Thread stack overrun warning message when calling the procedure p

      SET PATH test;
      CREATE PROCEDURE p() CALL p (SLEEP(1));
      SET PATH test1;
      CALL p();
      

      Leads to

      12.3.0-dbg>SET PATH test;
      Query OK, 0 rows affected (0.000 sec)
       
      12.3.0-dbg>CREATE PROCEDURE p() CALL p (SLEEP(1));
      Query OK, 0 rows affected (0.002 sec)
       
      12.3.0-dbg>SET PATH test1;
      Query OK, 0 rows affected (0.000 sec)
       
      12.3.0-dbg>CALL p();
      ERROR 1457 (HY000): Failed to load routine test.p (internal code -6). For more details, run SHOW WARNINGS
      12.3.0-dbg>SHOW WARNINGS;
      +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | Level | Code | Message                                                                                                                                        |
      +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | Error | 1436 | Thread stack overrun:  223200 bytes used of a 299008 byte stack, and 81920 bytes needed. Consider increasing the thread_stack system variable. |
      | Error | 1457 | Failed to load routine test.p (internal code -6). For more details, run SHOW WARNINGS                                                          |
      +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
      2 rows in set (0.000 sec)
       
      12.3.0-dbg>
      

      MDEV-34391 CS 12.3.0 a57c3210d7a9d9351c53af6190bafa466044f397 (Optimized, UBASAN, Clang 18.1.3-11) Build 23/12/2025

      Core was generated by `/test/mtest/MDEV-34391/UBASAN_MD231225-mariadb-12.3.0-linux-x86_64-opt/bin/mari'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x0000579cba20b1aa in Sp_handler::db_load_routine (this=<optimized out>, thd=<optimized out>, name=<optimized out>, sphp=<optimized out>, sql_mode=<optimized out>, sql_path=..., params=..., returns=..., body=..., chistics=..., definer=..., created=<optimized out>, modified=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:981
       
      [Current thread is 1 (LWP 824725)]
      (gdb) bt
      #0  0x0000579cba20b1aa in Sp_handler::db_load_routine (this=<optimized out>, thd=<optimized out>, 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-34391/12.3_opt_san/sql/sp.cc:981
      #1  0x0000579cba20a9f7 in Sp_handler::db_find_routine (this=<optimized out>, thd=0x52b000165218, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:776
      #2  0x0000579cba20cff8 in Sp_handler::db_find_and_cache_routine (this=0x579cbcf8fb40 <sp_handler_procedure>, thd=thd@entry=0x52b000165218, name=name@entry=0x7ad43ce26aa0, sp=sp@entry=0x7ad43cccbb20)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:800
      #3  0x0000579cba21da94 in Sp_handler::sp_find_routine (this=0x579cbcf8fb40 <sp_handler_procedure>, thd=<optimized out>, name=<optimized out>, cache_only=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:2257
      #4  0x0000579cba195a04 in Sql_path::try_resolve_in_schema (this=<optimized out>, thd=<optimized out>, schema=@0x7ad43cf4a9c0: {<Lex_ident_db> = {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x503000025378 "test", length = 4}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, name=<optimized out>, sph=<optimized out>, pkgname=<optimized out>, resolved=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sql_path.cc:62
      #5  0x0000579cba196a14 in Sql_path::resolve (this=<optimized out>, thd=<optimized out>, caller=<optimized out>, name=0x525000a88200, sph=<optimized out>, pkgname=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sql_path.cc:171
      #6  0x0000579cba7a890a in LEX::call_statement_start (this=0x525000a89938, thd=<optimized out>, name=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sql_lex.cc:10200
      #7  0x0000579cba486462 in MYSQLparse (thd=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sql_yacc.yy:3361
      #8  0x0000579cba881cb0 in parse_sql (thd=thd@entry=0x52b000165218, parser_state=parser_state@entry=0x7ad43d0a5620, creation_ctx=creation_ctx@entry=0x525000a83370, do_pfs_digest=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sql_parse.cc:10315
      #9  0x0000579cba20dc05 in sp_compile (thd=0x52b000165218, defstr=<optimized out>, sql_mode=<optimized out>, parent=<optimized out>, creation_ctx=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:909
      [..]
      #231 0x0000579cba20a9f7 in Sp_handler::db_find_routine (this=<optimized out>, thd=0x52b000165218, name=<optimized out>, sphp=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:776
      #232 0x0000579cba20cff8 in Sp_handler::db_find_and_cache_routine (this=0x579cbcf8fb40 <sp_handler_procedure>, thd=thd@entry=0x52b000165218, name=name@entry=0x7ad43cdfbe20, sp=sp@entry=0x7ad43cda81a0)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:800
      #233 0x0000579cba21da94 in Sp_handler::sp_find_routine (this=0x579cbcf8fb40 <sp_handler_procedure>, thd=<optimized out>, name=<optimized out>, cache_only=<optimized out>)at /test/mtest/MDEV-34391/12.3_opt_san/sql/sp.cc:2257
      #234 0x0000579cba195a04 in Sql_path::try_resolve_in_schema (this=<optimized out>, thd=<optimized out>, schema=@0x7ad43cf37cc0: {<Lex_ident_db> = {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x503000024688 "test", length = 4}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, name=<optimized out>, 
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.