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

Memory leak when executing PS for query with IN subquery

Details

    Description

      For the following test case a statement memory leak is detected when the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON

      CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
      CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
      INSERT INTO t1 VALUES ('b'), ('a'), ('c');
      INSERT INTO t2 VALUES ('c'), ('d'), ('b');
      PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
      EXECUTE stmt;
      EXECUTE stmt;
      DEALLOCATE PREPARE stmt;
      DROP TABLE t1,t2;
      

      The leak is detected in the function Type_std_attributes::agg_item_set_converter()
      with the following memory allocation

             Item_direct_ref_to_item *ref=
               new (thd->mem_root) Item_direct_ref_to_item(thd, *arg);
      

      Attachments

        Issue Links

          Activity

            igor Igor Babaev (Inactive) created issue -
            igor Igor Babaev (Inactive) made changes -
            Field Original Value New Value
            Priority Major [ 3 ] Critical [ 2 ]
            igor Igor Babaev (Inactive) made changes -
            Assignee Igor Babaev [ igor ] Dmitry Shulga [ JIRAUSER47315 ]
            igor Igor Babaev (Inactive) made changes -
            shulga Dmitry Shulga made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            shulga Dmitry Shulga added a comment -

            The branch for review is bb-10.4-MDEV-32369

            shulga Dmitry Shulga added a comment - The branch for review is bb-10.4- MDEV-32369
            shulga Dmitry Shulga made changes -
            Assignee Dmitry Shulga [ JIRAUSER47315 ] Oleksandr Byelkin [ sanja ]
            Status In Progress [ 3 ] In Review [ 10002 ]

            OK to push

            sanja Oleksandr Byelkin added a comment - OK to push
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Dmitry Shulga [ JIRAUSER47315 ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            shulga Dmitry Shulga made changes -
            Fix Version/s 10.4.32 [ 29300 ]
            Fix Version/s 10.5.23 [ 29012 ]
            Fix Version/s 10.6.16 [ 29014 ]
            Fix Version/s 10.10.7 [ 29018 ]
            Fix Version/s 10.11.6 [ 29020 ]
            Fix Version/s 11.0.4 [ 29021 ]
            Fix Version/s 11.1.3 [ 29023 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            igor Igor Babaev (Inactive) made changes -
            Description For the following test case a statement memory leak is detected when the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON
            {code:sql}
            CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
            CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
            INSERT INTO t1 VALUES ('b'), ('a'), ('c');
            INSERT INTO t2 VALUES ('c'), ('d'), ('b');
            PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
            EXECUTE stmt;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            DROP TABLE t1,t1;
            {code}
            The leak is detected in the function Type_std_attributes::agg_item_set_converter()
            with the following memory allocation
            {code}
                   Item_direct_ref_to_item *ref=
                     new (thd->mem_root) Item_direct_ref_to_item(thd, *arg);
            {code}
            For the following test case a statement memory leak is detected when the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON
            {code:sql}
            CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
            CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
            INSERT INTO t1 VALUES ('b'), ('a'), ('c');
            INSERT INTO t2 VALUES ('c'), ('d'), ('b');
            PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
            EXECUTE stmt;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            DROP TABLE t1,t2
            ;
            {code}
            The leak is detected in the function Type_std_attributes::agg_item_set_converter()
            with the following memory allocation
            {code}
                   Item_direct_ref_to_item *ref=
                     new (thd->mem_root) Item_direct_ref_to_item(thd, *arg);
            {code}
            igor Igor Babaev (Inactive) made changes -
            Description For the following test case a statement memory leak is detected when the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON
            {code:sql}
            CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
            CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
            INSERT INTO t1 VALUES ('b'), ('a'), ('c');
            INSERT INTO t2 VALUES ('c'), ('d'), ('b');
            PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
            EXECUTE stmt;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            DROP TABLE t1,t2
            ;
            {code}
            The leak is detected in the function Type_std_attributes::agg_item_set_converter()
            with the following memory allocation
            {code}
                   Item_direct_ref_to_item *ref=
                     new (thd->mem_root) Item_direct_ref_to_item(thd, *arg);
            {code}
            For the following test case a statement memory leak is detected when the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON
            {code:sql}
            CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
            CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
            INSERT INTO t1 VALUES ('b'), ('a'), ('c');
            INSERT INTO t2 VALUES ('c'), ('d'), ('b');
            PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
            EXECUTE stmt;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            DROP TABLE t1,t2;
            {code}
            The leak is detected in the function Type_std_attributes::agg_item_set_converter()
            with the following memory allocation
            {code}
                   Item_direct_ref_to_item *ref=
                     new (thd->mem_root) Item_direct_ref_to_item(thd, *arg);
            {code}
            igor Igor Babaev (Inactive) made changes -

            The following test case fails if the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON

            CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
            CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
            INSERT INTO t1 VALUES ('b'), ('a'), ('c');
            INSERT INTO t2 VALUES ('c'), ('d'), ('b');
            PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
            EXECUTE stmt;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            DROP TABLE t1,t2;
            

            igor Igor Babaev (Inactive) added a comment - The following test case fails if the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON CREATE TABLE t1 (a varchar (10)) ENGINE=MYISAM; CREATE TABLE t2 (b varchar (10) CHARACTER SET utf8) ENGINE=MYISAM; INSERT INTO t1 VALUES ( 'b' ), ( 'a' ), ( 'c' ); INSERT INTO t2 VALUES ( 'c' ), ( 'd' ), ( 'b' ); PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)" ; EXECUTE stmt; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1,t2;

            People

              shulga Dmitry Shulga
              igor Igor Babaev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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