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

Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed in virtual THD::~THD()

    XMLWordPrintable

Details

    • Can result in hang or crash
    • Hide
      not repeatable after fix for MDEV-39127
      Show
      not repeatable after fix for MDEV-39127
    • Q2/2026 Server Maintenance

    Description

      --source include/have_innodb.inc
       
      SET query_alloc_block_size=1024;
      CREATE OR REPLACE TABLE t1(a INT) ENGINE=INNODB;
      INSERT INTO t1 VALUES (1),(2),(3);
      UPDATE t1 SET a = 10 WHERE a = 1 RETURNING OLD_VALUE(a) AS old_val, a;
      SELECT * FROM t1;
      

      Leads to

      MDEV-5092 CS 13.0.0 f6ee14c3b3463a0f8a1265b3ce12333dff5f7eb2 (Debug, Clang 18.1.3-11) Build 19/03/2026

      mariadbd: /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_class.cc:1950: virtual THD::~THD(): Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed.
      #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  0x00007e492b64527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      #4  0x00007e492b6288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007e492b62881b in __assert_fail_base (fmt=0x7e492b7d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
          assertion=assertion@entry=0x58448da5a3ff "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", 
          file=file@entry=0x58448da59e7e "/test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_class.cc", line=line@entry=1950, function=function@entry=0x58448da5a3eb "virtual THD::~THD()") at ./assert/assert.c:96
      #6  0x00007e492b63b517 in __assert_fail (assertion=0x58448da5a3ff "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", 
          file=0x58448da59e7e "/test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_class.cc", line=1950, function=0x58448da5a3eb "virtual THD::~THD()") at ./assert/assert.c:105
      #7  0x000058448c8a7bec in THD::~THD (this=0x7e4844000d58) at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_class.cc:1949
      #8  0x000058448c8a8009 in THD::~THD (this=0x7e4844000d58) at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_class.cc:1868
      #9  0x000058448cb3f39e in do_handle_one_connection (connect=0x0, put_in_cache=true) at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_connect.cc:1544
      #10 0x000058448cb3efce in handle_one_connection (arg=0x5844bd58fe08) at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_connect.cc:1415
      #11 0x00007e492b69caa4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
      #12 0x00007e492b729c6c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      When we execute the test case through CLI the server crashes with different stack trace (the error is sporadic and requires repeated executions to reproduce the issue)

      MDEV-5092 CS 13.0.0 f6ee14c3b3463a0f8a1265b3ce12333dff5f7eb2 (Debug, Clang 18.1.3-11) Build 19/03/2026

      Core was generated by `/test/mtest/MDEV-5092/MD190326-mariadb-13.0.0-linux-x86_64-dbg/bin/mariadbd --n'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00007bbc99ea9afd in unlink_chunk (p=p@entry=0x7bbbc002d9b0, av=0x7bbbc0000030) at ./malloc/malloc.c:1616
       
      [Current thread is 1 (LWP 4104054)]
      (gdb) bt
      #0  0x00007bbc99ea9afd in unlink_chunk (p=p@entry=0x7bbbc002d9b0, av=0x7bbbc0000030) at ./malloc/malloc.c:1616
      #1  0x00007bbc99eab0e3 in _int_free_create_chunk (nextsize=192, nextchunk=0x7bbbc002d9b0, size=<optimized out>, p=0x7bbbc002d1b0, av=0x7bbbc0000030) at ./malloc/malloc.c:4721
      #2  _int_free_merge_chunk (av=0x7bbbc0000030, p=0x7bbbc002d1b0, size=<optimized out>) at ./malloc/malloc.c:4700
      #3  0x00007bbc99eab43a in _int_free (av=0x7bbbc0000030, p=<optimized out>, have_lock=<optimized out>) at ./malloc/malloc.c:4646
      #4  0x00007bbc99eaddce in __GI___libc_free (mem=0x7bbbc002d1c0)at ./malloc/malloc.c:3398
      #5  0x00005c8eeb0836d5 in my_free (ptr=0x7bbbc002d1d8)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/mysys/my_malloc.c:218
      #6  0x00005c8eeb06f0b3 in root_free (root=0x7bbbc00070e0, ptr=0x7bbbc002d1d8, size=2016)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/mysys/my_alloc.c:77
      #7  0x00005c8eeb06fa04 in free_root (root=0x7bbbc00070e0, MyFlags=1)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/mysys/my_alloc.c:511
      #8  0x00005c8eea296dc2 in dispatch_command (command=COM_QUERY, thd=0x7bbbc0000d58, packet=0x7bbbc000b4e9 "", packet_length=69, blocking=true)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_parse.cc:2492
      #9  0x00005c8eea2984e3 in do_command (thd=0x7bbbc0000d58, blocking=true)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_parse.cc:1432
      #10 0x00005c8eea493229 in do_handle_one_connection (connect=0x5c8ef8ab4e88, put_in_cache=true)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_connect.cc:1503
      #11 0x00005c8eea492fce in handle_one_connection (arg=0x5c8ef8b3d608)at /test/mtest/MDEV-5092/bb-13.0-MDEV-5092_dbg/sql/sql_connect.cc:1415
      #12 0x00007bbc99e9caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #13 0x00007bbc99f29c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.