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

Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed in THD::~THD on PREPARE and SHUTDOWN, Warning: Memory not freed: 16448/16496/16808

Details

    Description

      MTR testcase:

      CREATE TABLE t (c1 INT, c2 DATE) TABLESPACE t STORAGE MEMORY;
        
      --let $_server_id= `SELECT @@server_id`
      --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
      --exec echo "wait" > $_expect_file_name
       
      --connect (c1,localhost,root,,)
       
      --error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
      PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2';
       
      --send shutdown
      --connection default
      --source include/wait_until_disconnected.inc
       
      --exec echo "restart" > $_expect_file_name
      --enable_reconnect
      --source include/wait_until_connected_again.inc
       
      drop table t;
      

      Possibly related to MDEV-21837, though there are some differences.

      CLI testcase:

      CREATE TABLE t (c1 INT, c2 DATE) TABLESPACE t STORAGE MEMORY;
      PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2';
      SHUTDOWN;
      

      Leads to:

      10.6.2 6c39eaeb126328e7813b146ecf652d51e4508981 (Debug)

      mysqld: /test/10.6_dbg/sql/sql_class.cc:1745: virtual THD::~THD(): Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed.
      

      10.6.2 6c39eaeb126328e7813b146ecf652d51e4508981 (Debug)

      Core was generated by `/test/MD120621-mariadb-10.6.2-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      [Current thread is 1 (Thread 0x150470d4a700 (LWP 3945354))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x0000150473908859 in __GI_abort () at abort.c:79
      #2  0x0000150473908729 in __assert_fail_base (fmt=0x150473a9e588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5648de91ede8 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=0x5648de91d068 "/test/10.6_dbg/sql/sql_class.cc", line=1745, function=<optimized out>) at assert.c:92
      #3  0x0000150473919f36 in __GI___assert_fail (assertion=assertion@entry=0x5648de91ede8 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=file@entry=0x5648de91d068 "/test/10.6_dbg/sql/sql_class.cc", line=line@entry=1745, function=function@entry=0x5648de91fc50 "virtual THD::~THD()") at assert.c:101
      #4  0x00005648ddc25b6f in THD::~THD (this=0x15042c000db8, __in_chrg=<optimized out>) at /test/10.6_dbg/sql/sql_class.cc:1745
      #5  0x00005648ddc25ba1 in THD::~THD (this=0x15042c000db8, __in_chrg=<optimized out>) at /test/10.6_dbg/sql/sql_class.cc:1660
      #6  0x00005648dddf1162 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5648e0bdd418, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1451
      #7  0x00005648dddf1293 in handle_one_connection (arg=arg@entry=0x5648e0bdd418) at /test/10.6_dbg/sql/sql_connect.cc:1312
      #8  0x00005648de29f166 in pfs_spawn_thread (arg=0x5648e0ac6078) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
      #9  0x0000150473e16609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #10 0x0000150473a05293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.2.39 (dbg), 10.3.30 (dbg), 10.4.20 (dbg), 10.5.11 (dbg), 10.6.2 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.2.39 (opt), 10.3.30 (opt), 10.4.20 (opt), 10.5.11 (opt), 10.6.2 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.34 (dbg), 5.7.34 (opt), 8.0.24 (dbg), 8.0.24 (opt)

      Attachments

        Issue Links

          Activity

            11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Optimized)

            Warning: Memory not freed: 16808
            

            With this testcase

            CREATE TABLE t (a INT KEY,b INT,FOREIGN KEY(b) REFERENCES t (a)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
            PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2';
            SHUTDOWN;
            

            Roel Roel Van de Paar added a comment - 11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Optimized) Warning: Memory not freed: 16808 With this testcase CREATE TABLE t (a INT KEY,b INT,FOREIGN KEY(b) REFERENCES t (a)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2'; SHUTDOWN;

            I can not repeat it

            CREATE TABLE t (c1 INT, c2 DATE) TABLESPACE t STORAGE MEMORY;
            PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2';
            main.test 'innodb'                       [ fail ]
                    Test ended at 2023-09-25 13:54:05
             
            CURRENT_TEST: main.test
            mysqltest: At line 4: query 'PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2'' failed: 1222: The used SELECT statements have a different number of columns
            

            sanja Oleksandr Byelkin added a comment - I can not repeat it CREATE TABLE t (c1 INT, c2 DATE) TABLESPACE t STORAGE MEMORY; PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2'; main.test 'innodb' [ fail ] Test ended at 2023-09-25 13:54:05   CURRENT_TEST: main.test mysqltest: At line 4: query 'PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2'' failed: 1222: The used SELECT statements have a different number of columns

            the test sacase from the first comet also returns with an error

            sanja Oleksandr Byelkin added a comment - the test sacase from the first comet also returns with an error

            Roel if error expected there is --error construction in the test

            sanja Oleksandr Byelkin added a comment - Roel if error expected there is --error construction in the test
            Roel Roel Van de Paar added a comment - - edited

            Slightly different stack when using threadpool. CLI testcase (same as original, with threadpool):

            # mysqld options required for replay:  --thread_handling=pool-of-threads
            CREATE TABLE t (c1 INT, c2 DATE) TABLESPACE t STORAGE MEMORY;
            PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2';
            SHUTDOWN;
            

            Leads to UniqueID:

            11.5.0 e4afa610539ae01164485554e2de839bea9de816 (Debug)

            status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory|SIGABRT|THD::~THD|THD::~THD|threadpool_remove_connection|tp_callback
            

            Full stack:

            11.5.0 e4afa610539ae01164485554e2de839bea9de816 (Debug)

            Core was generated by `/test/MD170524-mariadb-11.5.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'.
            Program terminated with signal SIGABRT, Aborted.
            #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
            Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
            [Current thread is 1 (LWP 2599206)]
            (gdb) bt
            #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
            #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
            #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
            #3  0x00001505fb242866 in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
            #4  0x00001505fb2268b7 in __GI_abort () at ./stdlib/abort.c:79
            #5  0x00001505fb2267db in __assert_fail_base (fmt=0x1505fb3c5168 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x561b16d4da90 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=file@entry=0x561b16d4c2f8 "/test/11.5_dbg/sql/sql_class.cc", line=line@entry=1812, function=function@entry=0x561b16ce1f88 "virtual THD::~THD()")at ./assert/assert.c:92
            #6  0x00001505fb239186 in __assert_fail (assertion=0x561b16d4da90 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=0x561b16d4c2f8 "/test/11.5_dbg/sql/sql_class.cc", line=1812, function=0x561b16ce1f88 "virtual THD::~THD()")at ./assert/assert.c:101
            #7  0x0000561b1606eb84 in THD::~THD (this=0x15059c001168, __in_chrg=<optimized out>) at /test/11.5_dbg/sql/sql_class.cc:1812
            #8  0x0000561b1606ef33 in THD::~THD (this=0x15059c001168, __in_chrg=<optimized out>) at /test/11.5_dbg/sql/sql_class.cc:1818
            #9  0x0000561b1635b962 in threadpool_remove_connection (thd=thd@entry=0x15059c001168)at /test/11.5_dbg/sql/threadpool_common.cc:359
            #10 0x0000561b1635be27 in tp_callback (c=0x561b18fc7820)at /test/11.5_dbg/sql/threadpool_common.cc:285
            #11 0x0000561b165bd6fe in worker_main (param=param@entry=0x561b18f13ed8)at /test/11.5_dbg/sql/threadpool_generic.cc:1556
            #12 0x0000561b16694980 in pfs_spawn_thread (arg=0x561b19004c98)at /test/11.5_dbg/storage/perfschema/pfs.cc:2201
            #13 0x00001505fb297ada in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:444
            #14 0x00001505fb32847c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
            

            Roel Roel Van de Paar added a comment - - edited Slightly different stack when using threadpool. CLI testcase (same as original, with threadpool): # mysqld options required for replay: --thread_handling=pool-of-threads CREATE TABLE t (c1 INT , c2 DATE ) TABLESPACE t STORAGE MEMORY; PREPARE s FROM 'WITH RECURSIVE d AS (SELECT * FROM t UNION ALL SELECT 1 FROM d) SELECT * FROM d AS d1,d AS d2' ; SHUTDOWN; Leads to UniqueID: 11.5.0 e4afa610539ae01164485554e2de839bea9de816 (Debug) status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory|SIGABRT|THD::~THD|THD::~THD|threadpool_remove_connection|tp_callback Full stack: 11.5.0 e4afa610539ae01164485554e2de839bea9de816 (Debug) Core was generated by `/test/MD170524-mariadb-11.5.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'. Program terminated with signal SIGABRT, Aborted. #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44 Download failed: Invalid argument. Continuing without source file ./nptl/./nptl/pthread_kill.c. [Current thread is 1 (LWP 2599206)] (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89 #3 0x00001505fb242866 in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26 #4 0x00001505fb2268b7 in __GI_abort () at ./stdlib/abort.c:79 #5 0x00001505fb2267db in __assert_fail_base (fmt=0x1505fb3c5168 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x561b16d4da90 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=file@entry=0x561b16d4c2f8 "/test/11.5_dbg/sql/sql_class.cc", line=line@entry=1812, function=function@entry=0x561b16ce1f88 "virtual THD::~THD()")at ./assert/assert.c:92 #6 0x00001505fb239186 in __assert_fail (assertion=0x561b16d4da90 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=0x561b16d4c2f8 "/test/11.5_dbg/sql/sql_class.cc", line=1812, function=0x561b16ce1f88 "virtual THD::~THD()")at ./assert/assert.c:101 #7 0x0000561b1606eb84 in THD::~THD (this=0x15059c001168, __in_chrg=<optimized out>) at /test/11.5_dbg/sql/sql_class.cc:1812 #8 0x0000561b1606ef33 in THD::~THD (this=0x15059c001168, __in_chrg=<optimized out>) at /test/11.5_dbg/sql/sql_class.cc:1818 #9 0x0000561b1635b962 in threadpool_remove_connection (thd=thd@entry=0x15059c001168)at /test/11.5_dbg/sql/threadpool_common.cc:359 #10 0x0000561b1635be27 in tp_callback (c=0x561b18fc7820)at /test/11.5_dbg/sql/threadpool_common.cc:285 #11 0x0000561b165bd6fe in worker_main (param=param@entry=0x561b18f13ed8)at /test/11.5_dbg/sql/threadpool_generic.cc:1556 #12 0x0000561b16694980 in pfs_spawn_thread (arg=0x561b19004c98)at /test/11.5_dbg/storage/perfschema/pfs.cc:2201 #13 0x00001505fb297ada in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:444 #14 0x00001505fb32847c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

            People

              sanja Oleksandr Byelkin
              Roel Roel Van de Paar
              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.