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

Assertion `global_status_var.global_memory_used == 0' failed, bytes lost, or LeakSanitizer: detected memory leaks after using temporary table with fulltext key

    XMLWordPrintable

Details

    Description

      CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=MyISAM;
      ALTER TABLE tmp ADD FULLTEXT (a);
      INSERT INTO tmp VALUES ('foo');
      

      On a debug build (all versions) it causes the assertion failure upon shutdown:

      10.4 9eae063e

      Warning: 65496 bytes lost at 0x7f96b4046fa0, allocated by T@0 at 0x562cd9983c00, 0x562cd987733b, 0x562cd98dedd0, 0x562cd98df44b, 0x562cd98c09b1, 0x562cd987b86b, 0x562cd91296be, 0x562cd8d75b7a
      Memory lost: 65496 bytes in 1 chunks
      mysqld: /data/src/10.4/sql/mysqld.cc:1944: void mysqld_exit(int): Assertion `global_status_var.global_memory_used == 0' failed.
      200417 13:52:16 [ERROR] mysqld got signal 6 ;
       
      #6  <signal handler called>
      #7  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #8  0x00007f96cca48535 in __GI_abort () at abort.c:79
      #9  0x00007f96cca4840f in __assert_fail_base (fmt=0x7f96ccbaaee0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x562cd9a73458 "global_status_var.global_memory_used == 0", file=0x562cd9a730b6 "/data/src/10.4/sql/mysqld.cc", line=1944, function=<optimized out>) at assert.c:92
      #10 0x00007f96cca56102 in __GI___assert_fail (assertion=0x562cd9a73458 "global_status_var.global_memory_used == 0", file=0x562cd9a730b6 "/data/src/10.4/sql/mysqld.cc", line=1944, function=0x562cd9a7bd20 <mysqld_exit(int)::__PRETTY_FUNCTION__> "void mysqld_exit(int)") at assert.c:101
      #11 0x0000562cd8c7ae06 in mysqld_exit (exit_code=0) at /data/src/10.4/sql/mysqld.cc:1944
      #12 0x0000562cd8c836d6 in mysqld_main (argc=130, argv=0x562cdc8898e0) at /data/src/10.4/sql/mysqld.cc:5951
      #13 0x0000562cd8c77285 in main (argc=6, argv=0x7fffcec119e8) at /data/src/10.4/sql/main.cc:25
      

      If it's run with debug_assert_on_not_freed_memory=0, the assertion is skipped, but "bytes lost" warning is still there.

      On a non-debug (RelWithDebInfo) build with ASAN, if it's built with older versions, LeakSanitizer produces warnings, observed with gcc 6.3.0, and gcc 7.4.0.

      With gcc 6.3.0

      ==5574==ERROR: LeakSanitizer: detected memory leaks
       
      Direct leak of 65504 byte(s) in 1 object(s) allocated from:
          #0 0x7fd7801dbd28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x55a3f4e04f7c in my_malloc /data/src/10.4/mysys/my_malloc.c:101
       
      SUMMARY: AddressSanitizer: 65504 byte(s) leaked in 1 allocation(s).
      

      On a build with gcc 8.3.0, LeakSanitizer remains silent, but the assertion failure is still there.

      Reproducible with MyISAM and Aria. InnoDB doesn't allow FULLTEXT indexes on temporary tables.

      Stack trace obtained on a non-debug ASAN build with -BUILD_CONFIG=mysql_release:

      10.2 ccaec18b393

      ==21445==ERROR: LeakSanitizer: detected memory leaks
       
      Direct leak of 65504 byte(s) in 1 object(s) allocated from:
          #0 0x7f88f6e0b330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
          #1 0x564e8b4412ee in my_malloc /data/src/10.2-bug/mysys/my_malloc.c:101
          #2 0x564e8b42ba11 in alloc_root /data/src/10.2-bug/mysys/my_alloc.c:242
          #3 0x564e8b113b2b in ft_linearize /data/src/10.2-bug/storage/myisam/ft_parser.c:54
          #4 0x564e8b1f80b3 in _mi_ft_parserecord /data/src/10.2-bug/storage/myisam/ft_update.c:129
          #5 0x564e8b1f99cf in _mi_ft_add /data/src/10.2-bug/storage/myisam/ft_update.c:251
          #6 0x564e8b1bcce3 in mi_write /data/src/10.2-bug/storage/myisam/mi_write.c:115
          #7 0x564e8a29acb1 in handler::ha_write_row(unsigned char*) /data/src/10.2-bug/sql/handler.cc:6095
          #8 0x564e89c6aab4 in write_record(THD*, TABLE*, st_copy_info*) /data/src/10.2-bug/sql/sql_insert.cc:1941
          #9 0x564e89c91537 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) /data/src/10.2-bug/sql/sql_insert.cc:1066
          #10 0x564e89cdf824 in mysql_execute_command(THD*) /data/src/10.2-bug/sql/sql_parse.cc:4166
          #11 0x564e89cf252f in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2-bug/sql/sql_parse.cc:7739
          #12 0x564e89cfa063 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2-bug/sql/sql_parse.cc:1830
          #13 0x564e89cfc6b7 in do_command(THD*) /data/src/10.2-bug/sql/sql_parse.cc:1384
          #14 0x564e89feaade in do_handle_one_connection(CONNECT*) /data/src/10.2-bug/sql/sql_connect.cc:1336
          #15 0x564e89feb1ba in handle_one_connection /data/src/10.2-bug/sql/sql_connect.cc:1241
          #16 0x564e8b29854a in pfs_spawn_thread /data/src/10.2-bug/storage/perfschema/pfs.cc:1869
          #17 0x7f88f6d08fa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486
       
      SUMMARY: AddressSanitizer: 65504 byte(s) leaked in 1 allocation(s).
      

      Attachments

        Activity

          People

            monty Michael Widenius
            elenst Elena Stepanova
            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.