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

LeakSanitizer errors in MHNSW_Share::alloc_node after DML on empty table with vector key

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 11.8
    • 11.8.3
    • Vector search
    • None
    • Can result in unexpected behaviour
    • Q3/2025 Maintenance

    Description

      CREATE TABLE t (v VECTOR(1) NOT NULL, VECTOR(v)) ENGINE=MyISAM;
      DELETE FROM t;
      INSERT INTO t VALUES (0x31313131);
      DELETE FROM t;
       
      DROP TABLE t;
      

      11.8 865b05bf4acf10e0d4b3359019ed7b2efe0be81d

      Warning: Internal memory accounting error of 1053160 bytes
       
      =================================================================
      ==3937480==ERROR: LeakSanitizer: detected memory leaks
       
      Direct leak of 296 byte(s) in 1 object(s) allocated from:
          #0 0x7f37fb2b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x55ba107de09f in my_malloc /data/bld/11.8-asan-ubsan/mysys/my_malloc.c:93
          #2 0x55ba107b01ff in my_multi_malloc /data/bld/11.8-asan-ubsan/mysys/mulalloc.c:59
          #3 0x55ba107fb117 in safe_mutex_lazy_init_deadlock_detection /data/bld/11.8-asan-ubsan/mysys/thr_mutex.c:155
          #4 0x55ba107fca42 in safe_mutex_lock /data/bld/11.8-asan-ubsan/mysys/thr_mutex.c:312
          #5 0x55ba0f061c83 in inline_mysql_mutex_lock /data/bld/11.8-asan-ubsan/include/mysql/psi/mysql_thread.h:750
          #6 0x55ba0f0858ae in MHNSW_Share::alloc_node() /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:544
          #7 0x55ba0f074467 in mhnsw_insert(TABLE*, st_key*) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:1266
          #8 0x55ba0ceea800 in TABLE::hlindexes_on_insert() /data/bld/11.8-asan-ubsan/sql/sql_base.cc:9957
          #9 0x55ba0e6c57ef in handler::ha_write_row(unsigned char const*) /data/bld/11.8-asan-ubsan/sql/handler.cc:8224
          #10 0x55ba0d0bb587 in write_record(THD*, TABLE*, st_copy_info*, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:2332
          #11 0x55ba0d0fa43f in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:1159
          #12 0x55ba0d28d52d in mysql_execute_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:4484
          #13 0x55ba0d2a5c78 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:7915
          #14 0x55ba0d2aef8e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1902
          #15 0x55ba0d2bbe9c in do_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1415
          #16 0x55ba0dafc58f in do_handle_one_connection(CONNECT*, bool) /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1415
          #17 0x55ba0dafd6f8 in handle_one_connection /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1327
          #18 0x55ba0f598a79 in pfs_spawn_thread /data/bld/11.8-asan-ubsan/storage/perfschema/pfs.cc:2198
          #19 0x7f37f9ea81c3 in start_thread nptl/pthread_create.c:442
       
      Direct leak of 152 byte(s) in 1 object(s) allocated from:
          #0 0x7f37fb2b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x55ba107de09f in my_malloc /data/bld/11.8-asan-ubsan/mysys/my_malloc.c:93
          #2 0x55ba1075bb4d in init_dynamic_array2 /data/bld/11.8-asan-ubsan/mysys/array.c:73
          #3 0x55ba1076eb5b in my_hash_init2 /data/bld/11.8-asan-ubsan/mysys/hash.c:99
          #4 0x55ba0f07ceee in Hash_set<FVectorNode>::Hash_set(unsigned int, unsigned char const* (*)(void const*, unsigned long*, char), charset_info_st const*) /data/bld/11.8-asan-ubsan/sql/sql_hset.h:38
          #5 0x55ba0f07d066 in MHNSW_Share::MHNSW_Share(TABLE*) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:448
          #6 0x55ba0f067690 in MHNSW_Share::get_from_share(TABLE_SHARE*, TABLE*) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:749
          #7 0x55ba0f06c12f in MHNSW_Share::acquire(MHNSW_Share**, TABLE*, bool) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:768
          #8 0x55ba0f06efab in mhnsw_delete_all(TABLE*, st_key*, bool) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:1545
          #9 0x55ba0ceeb688 in TABLE::hlindexes_on_delete_all(bool) /data/bld/11.8-asan-ubsan/sql/sql_base.cc:9991
          #10 0x55ba0e68fce9 in handler::ha_delete_all_rows() /data/bld/11.8-asan-ubsan/sql/handler.cc:5531
          #11 0x55ba0d04f293 in Sql_cmd_delete::delete_from_single_table(THD*) /data/bld/11.8-asan-ubsan/sql/sql_delete.cc:472
          #12 0x55ba0d05ebb4 in Sql_cmd_delete::execute_inner(THD*) /data/bld/11.8-asan-ubsan/sql/sql_delete.cc:2079
          #13 0x55ba0d41a953 in Sql_cmd_dml::execute(THD*) /data/bld/11.8-asan-ubsan/sql/sql_select.cc:34491
          #14 0x55ba0d28bdf3 in mysql_execute_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:4428
          #15 0x55ba0d2a5c78 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:7915
          #16 0x55ba0d2aef8e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1902
          #17 0x55ba0d2bbe9c in do_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1415
          #18 0x55ba0dafc58f in do_handle_one_connection(CONNECT*, bool) /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1415
          #19 0x55ba0dafd6f8 in handle_one_connection /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1327
          #20 0x55ba0f598a79 in pfs_spawn_thread /data/bld/11.8-asan-ubsan/storage/perfschema/pfs.cc:2198
          #21 0x7f37f9ea81c3 in start_thread nptl/pthread_create.c:442
       
      Indirect leak of 1048568 byte(s) in 1 object(s) allocated from:
          #0 0x7f37fb2b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x55ba107de09f in my_malloc /data/bld/11.8-asan-ubsan/mysys/my_malloc.c:93
          #2 0x55ba107b12d0 in root_alloc /data/bld/11.8-asan-ubsan/mysys/my_alloc.c:66
          #3 0x55ba107b28ce in alloc_root /data/bld/11.8-asan-ubsan/mysys/my_alloc.c:336
          #4 0x55ba0f0854cf in MHNSW_Share::alloc_node_internal() /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:422
          #5 0x55ba0f08591a in MHNSW_Share::alloc_node() /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:545
          #6 0x55ba0f074467 in mhnsw_insert(TABLE*, st_key*) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:1266
          #7 0x55ba0ceea800 in TABLE::hlindexes_on_insert() /data/bld/11.8-asan-ubsan/sql/sql_base.cc:9957
          #8 0x55ba0e6c57ef in handler::ha_write_row(unsigned char const*) /data/bld/11.8-asan-ubsan/sql/handler.cc:8224
          #9 0x55ba0d0bb587 in write_record(THD*, TABLE*, st_copy_info*, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:2332
          #10 0x55ba0d0fa43f in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:1159
          #11 0x55ba0d28d52d in mysql_execute_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:4484
          #12 0x55ba0d2a5c78 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:7915
          #13 0x55ba0d2aef8e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1902
          #14 0x55ba0d2bbe9c in do_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1415
          #15 0x55ba0dafc58f in do_handle_one_connection(CONNECT*, bool) /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1415
          #16 0x55ba0dafd6f8 in handle_one_connection /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1327
          #17 0x55ba0f598a79 in pfs_spawn_thread /data/bld/11.8-asan-ubsan/storage/perfschema/pfs.cc:2198
          #18 0x7f37f9ea81c3 in start_thread nptl/pthread_create.c:442
       
      Indirect leak of 2072 byte(s) in 1 object(s) allocated from:
          #0 0x7f37fb2b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x55ba107de09f in my_malloc /data/bld/11.8-asan-ubsan/mysys/my_malloc.c:93
          #2 0x55ba1075bb4d in init_dynamic_array2 /data/bld/11.8-asan-ubsan/mysys/array.c:73
          #3 0x55ba1076eb5b in my_hash_init2 /data/bld/11.8-asan-ubsan/mysys/hash.c:99
          #4 0x55ba107fb212 in safe_mutex_lazy_init_deadlock_detection /data/bld/11.8-asan-ubsan/mysys/thr_mutex.c:171
          #5 0x55ba107fca42 in safe_mutex_lock /data/bld/11.8-asan-ubsan/mysys/thr_mutex.c:312
          #6 0x55ba0f061c83 in inline_mysql_mutex_lock /data/bld/11.8-asan-ubsan/include/mysql/psi/mysql_thread.h:750
          #7 0x55ba0f0858ae in MHNSW_Share::alloc_node() /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:544
          #8 0x55ba0f074467 in mhnsw_insert(TABLE*, st_key*) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:1266
          #9 0x55ba0ceea800 in TABLE::hlindexes_on_insert() /data/bld/11.8-asan-ubsan/sql/sql_base.cc:9957
          #10 0x55ba0e6c57ef in handler::ha_write_row(unsigned char const*) /data/bld/11.8-asan-ubsan/sql/handler.cc:8224
          #11 0x55ba0d0bb587 in write_record(THD*, TABLE*, st_copy_info*, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:2332
          #12 0x55ba0d0fa43f in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:1159
          #13 0x55ba0d28d52d in mysql_execute_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:4484
          #14 0x55ba0d2a5c78 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:7915
          #15 0x55ba0d2aef8e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1902
          #16 0x55ba0d2bbe9c in do_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1415
          #17 0x55ba0dafc58f in do_handle_one_connection(CONNECT*, bool) /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1415
          #18 0x55ba0dafd6f8 in handle_one_connection /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1327
          #19 0x55ba0f598a79 in pfs_spawn_thread /data/bld/11.8-asan-ubsan/storage/perfschema/pfs.cc:2198
          #20 0x7f37f9ea81c3 in start_thread nptl/pthread_create.c:442
       
      Indirect leak of 2072 byte(s) in 1 object(s) allocated from:
          #0 0x7f37fb2b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x55ba107de09f in my_malloc /data/bld/11.8-asan-ubsan/mysys/my_malloc.c:93
          #2 0x55ba1075bb4d in init_dynamic_array2 /data/bld/11.8-asan-ubsan/mysys/array.c:73
          #3 0x55ba1076eb5b in my_hash_init2 /data/bld/11.8-asan-ubsan/mysys/hash.c:99
          #4 0x55ba107fb1bc in safe_mutex_lazy_init_deadlock_detection /data/bld/11.8-asan-ubsan/mysys/thr_mutex.c:168
          #5 0x55ba107fca42 in safe_mutex_lock /data/bld/11.8-asan-ubsan/mysys/thr_mutex.c:312
          #6 0x55ba0f061c83 in inline_mysql_mutex_lock /data/bld/11.8-asan-ubsan/include/mysql/psi/mysql_thread.h:750
          #7 0x55ba0f0858ae in MHNSW_Share::alloc_node() /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:544
          #8 0x55ba0f074467 in mhnsw_insert(TABLE*, st_key*) /data/bld/11.8-asan-ubsan/sql/vector_mhnsw.cc:1266
          #9 0x55ba0ceea800 in TABLE::hlindexes_on_insert() /data/bld/11.8-asan-ubsan/sql/sql_base.cc:9957
          #10 0x55ba0e6c57ef in handler::ha_write_row(unsigned char const*) /data/bld/11.8-asan-ubsan/sql/handler.cc:8224
          #11 0x55ba0d0bb587 in write_record(THD*, TABLE*, st_copy_info*, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:2332
          #12 0x55ba0d0fa43f in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/bld/11.8-asan-ubsan/sql/sql_insert.cc:1159
          #13 0x55ba0d28d52d in mysql_execute_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:4484
          #14 0x55ba0d2a5c78 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:7915
          #15 0x55ba0d2aef8e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1902
          #16 0x55ba0d2bbe9c in do_command(THD*, bool) /data/bld/11.8-asan-ubsan/sql/sql_parse.cc:1415
          #17 0x55ba0dafc58f in do_handle_one_connection(CONNECT*, bool) /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1415
          #18 0x55ba0dafd6f8 in handle_one_connection /data/bld/11.8-asan-ubsan/sql/sql_connect.cc:1327
          #19 0x55ba0f598a79 in pfs_spawn_thread /data/bld/11.8-asan-ubsan/storage/perfschema/pfs.cc:2198
          #20 0x7f37f9ea81c3 in start_thread nptl/pthread_create.c:442
       
      SUMMARY: AddressSanitizer: 1053160 byte(s) leaked in 5 allocation(s).
      250507  0:39:18 [ERROR] /share8t/bld/11.8-asan-ubsan/sql/mariadbd got signal 6 ;
      Sorry, we probably made a mistake, and this is a bug.
       
      Your assistance in bug reporting will enable us to fix this for the next release.
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs about how to report
      a bug on https://jira.mariadb.org/.
       
      Please include the information from the server start above, to the end of the
      information below.
       
      Server version: 11.8.1-MariaDB-debug-log source revision: 865b05bf4acf10e0d4b3359019ed7b2efe0be81d
       
      The information page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mariadbd/
      contains instructions to obtain a better version of the backtrace below.
      Following these instructions will help MariaDB developers provide a fix quicker.
       
      Attempting backtrace. Include this in the bug report.
      (note: Retrieving this information may fail)
       
      Thread pointer: 0x0
      stack_bottom = 0x0 thread_stack 0xb00000
      sanitizer_common/sanitizer_common_interceptors.inc:4277(__interceptor_backtrace.part.0)[0x7f37fb251f31]
      mysys/stacktrace.c:215(my_print_stacktrace)[0x55ba107f092a]
      sql/signal_handler.cc:227(handle_fatal_signal)[0x55ba0e634cd9]
      libc_sigaction.c:0(__restore_rt)[0x7f37f9e5b050]
      nptl/pthread_kill.c:44(__pthread_kill_implementation)[0x7f37f9ea9ebc]
      posix/raise.c:27(__GI_raise)[0x7f37f9e5afb2]
      stdlib/abort.c:81(__GI_abort)[0x7f37f9e45472]
      sanitizer_common/sanitizer_posix_libcdep.cpp:137(__sanitizer::Abort())[0x7f37fb2d650f]
      sanitizer_common/sanitizer_termination.cpp:59(__sanitizer::Die())[0x7f37fb2e2ba1]
      lsan/lsan_common_linux.cpp:120(__lsan::HandleLeaks())[0x7f37fb2ea87c]
      lsan/lsan_common.cpp:732(__lsan::DoLeakCheck())[0x7f37fb2e8dc5]
      stdlib/cxa_finalize.c:84(__cxa_finalize)[0x7f37f9e5cff7]
      crtstuff.c:0(__do_global_dtors_aux)[0x7f37fb224bc7]
      Writing a core file...
      Working directory at /dev/shm/var_auto_T1P7/mysqld.1/data
      Resource Limits (excludes unlimited resources):
      Limit                     Soft Limit           Hard Limit           Units     
      Max stack size            8388608              unlimited            bytes     
      Max processes             514196               514196               processes 
      Max open files            65536                65536                files     
      Max locked memory         16854077440          16854077440          bytes     
      Max pending signals       514196               514196               signals   
      Max msgqueue size         819200               819200               bytes     
      Max nice priority         0                    0                    
      Max realtime priority     0                    0                    
      Core pattern: core
       
      Kernel version: Linux version 6.1.0-27-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01)
      

      "Warning: Internal memory accounting error of 1048720 bytes" also happens on a non-debug build.

      Attachments

        Activity

          People

            alessandro.vetere Alessandro Vetere
            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.