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

Crash or stack overrun when using its own package routine as DEFAULT

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.8, 12.3, 13.2
    • 11.8
    • Stored routines
    • None
    • Can result in hang or crash

    Description

      Crash or stack overrun when using its own package routine as DEFAULT

      The script below produces a stack overrun error, but also can crash occasionally. It should not produce any errors and parse with success. The routine pkgx.g() obviously refers to g() of this package pkgx, just using the qualified notation. It should work like if it was written FUNCTION f(a BIGINT := pkgx.g()) RETURN BIGINT;:

      SET sql_mode=ORACLE;
      DELIMITER $$ 
      CREATE OR REPLACE PACKAGE pkgx AS
        FUNCTION g RETURN BIGINT;
        FUNCTION f(a BIGINT := pkgx.g()) RETURN BIGINT;
      END;
      $$
      CREATE PACKAGE BODY pkgx AS
        FUNCTION g RETURN BIGINT AS
        BEGIN
          RETURN 1;
        END;
        FUNCTION f(a BIGINT := pkgx.g()) RETURN BIGINT AS
        BEGIN
          RETURN a;
        END;
      END;
      $$
      DELIMITER ;
      SELECT pkgx.f();
      SHOW WARNINGS;
      

      ERROR 1457 (HY000): Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS
      MariaDB [test]> DELIMITER ;
      MariaDB [test]> SELECT pkgx.f();
      ERROR 1457 (HY000): Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS
      +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | Level | Code | Message                                                                                                                                        |
      +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | Error | 1436 | Thread stack overrun:  229392 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.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      | Error | 1457 | Failed to load routine test.pkgx (internal code -6). For more details, run SHOW WARNINGS                                                       |
      +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
      

      Attachments

        Issue Links

          Activity

            People

              Khaled.amr Khaled Amr
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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

                  Git Integration

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