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

MSAN_OPTIONS=poison_in_dtor=1 DEALLOCATE PREPARE stmt

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      buildbot@b9701de41d41:/build$ MSAN_OPTIONS=abort_on_error=1 mysql-test/mtr --ps-protocol --suite=main --force-restart
      Logging: /source/mysql-test/mariadb-test-run.pl  --ps-protocol --suite=main --force-restart
       
      main.ps                                  w3 [ fail ]
              Test ended at 2026-08-08 03:12:25
       
      CURRENT_TEST: main.ps
      /build/client//mariadb-test: Error on delete of '/build/mysql-test/var/3/tmp/f1.txt' (Errcode: 2 "No such file or directory")
      mysqltest: At line 5571: query 'DEALLOCATE PREPARE stmt' failed: <Unknown> (2013): Lost connection to server during query
       
      ==29804==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x5563c3563733 in sp_lex_keeper::~sp_lex_keeper() /source/sql/sp_instr.h:279:9
          #1 0x5563c3563733 in sp_lex_instr::~sp_lex_instr() /source/sql/sp_instr.h:431:3
          #2 0x5563c3b849c1 in sp_instr_stmt::~sp_instr_stmt() /source/sql/sp_instr.h:570:36
          #3 0x5563c3b849c1 in sp_instr_stmt::~sp_instr_stmt() /source/sql/sp_instr.h:570:36
          #4 0x5563c3359235 in sp_head::~sp_head() /source/sql/sp_head.cc:902:5
          #5 0x5563c335cb5d in sp_head::~sp_head() /source/sql/sp_head.cc:894:1
          #6 0x5563c335814d in sp_head::destroy(sp_head*) /source/sql/sp_head.cc:536:5
          #7 0x5563c34f1302 in lex_end_nops(LEX*) /source/sql/sql_lex.cc:1385:3
          #8 0x5563c34f1302 in lex_end(LEX*) /source/sql/sql_lex.cc:1354:3
          #9 0x5563c361ff4f in Prepared_statement::deallocate_immediate() /source/sql/sql_prepare.cc:5290:3
          #10 0x5563c361ff4f in Prepared_statement::deallocate() /source/sql/sql_prepare.cc:5298:3
          #11 0x5563c361ff4f in mysql_sql_stmt_close(THD*) /source/sql/sql_prepare.cc:3702:11
          #12 0x5563c359eb49 in mysql_execute_command(THD*, bool) /source/sql/sql_parse.cc:4031:5
          #13 0x5563c358abc0 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /source/sql/sql_parse.cc:7941:18
          #14 0x5563c3583f58 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /source/sql/sql_parse.cc:1925:7
          #15 0x5563c358bbeb in do_command(THD*, bool) /source/sql/sql_parse.cc:1433:17
          #16 0x5563c39c4cfc in do_handle_one_connection(CONNECT*, bool) /source/sql/sql_connect.cc:1508:11
          #17 0x5563c39c47b5 in handle_one_connection /source/sql/sql_connect.cc:1420:5
          #18 0x5563c456d859 in pfs_spawn_thread /source/storage/perfschema/pfs.cc:2201:3
          #19 0x7f8922973b7a  (/lib/x86_64-linux-gnu/libc.so.6+0x92b7a) (BuildId: c495b62edadd6c356265942ec1282d98058a7b41)
          #20 0x7f89229f17f7  (/lib/x86_64-linux-gnu/libc.so.6+0x1107f7) (BuildId: c495b62edadd6c356265942ec1282d98058a7b41)
       
        Member fields were destroyed
          #0 0x5563c31c5fc1 in __sanitizer_dtor_callback_fields (/build/sql/mariadbd+0x811fc1) (BuildId: 3e2292338eb16b5bfaaded2fc132451c9f3a9ea8)
          #1 0x5563c3563549 in sp_lex_keeper::~sp_lex_keeper() /source/sql/sp_instr.h:361:8
          #2 0x5563c3563549 in sp_lex_keeper::~sp_lex_keeper() /source/sql/sp_instr.h:288:3
          #3 0x5563c3563549 in sp_lex_instr::~sp_lex_instr() /source/sql/sp_instr.h:421:20
          #4 0x5563c3b849c1 in sp_instr_stmt::~sp_instr_stmt() /source/sql/sp_instr.h:570:36
          #5 0x5563c3b849c1 in sp_instr_stmt::~sp_instr_stmt() /source/sql/sp_instr.h:570:36
          #6 0x5563c3359235 in sp_head::~sp_head() /source/sql/sp_head.cc:902:5
          #7 0x5563c335cb5d in sp_head::~sp_head() /source/sql/sp_head.cc:894:1
          #8 0x5563c335814d in sp_head::destroy(sp_head*) /source/sql/sp_head.cc:536:5
          #9 0x5563c34f1302 in lex_end_nops(LEX*) /source/sql/sql_lex.cc:1385:3
          #10 0x5563c34f1302 in lex_end(LEX*) /source/sql/sql_lex.cc:1354:3
          #11 0x5563c361ff4f in Prepared_statement::deallocate_immediate() /source/sql/sql_prepare.cc:5290:3
          #12 0x5563c361ff4f in Prepared_statement::deallocate() /source/sql/sql_prepare.cc:5298:3
          #13 0x5563c361ff4f in mysql_sql_stmt_close(THD*) /source/sql/sql_prepare.cc:3702:11
          #14 0x5563c359eb49 in mysql_execute_command(THD*, bool) /source/sql/sql_parse.cc:4031:5
          #15 0x5563c358abc0 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /source/sql/sql_parse.cc:7941:18
          #16 0x5563c3583f58 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /source/sql/sql_parse.cc:1925:7
          #17 0x5563c358bbeb in do_command(THD*, bool) /source/sql/sql_parse.cc:1433:17
          #18 0x5563c39c4cfc in do_handle_one_connection(CONNECT*, bool) /source/sql/sql_connect.cc:1508:11
          #19 0x5563c39c47b5 in handle_one_connection /source/sql/sql_connect.cc:1420:5
          #20 0x5563c456d859 in pfs_spawn_thread /source/storage/perfschema/pfs.cc:2201:3
          #21 0x7f8922973b7a  (/lib/x86_64-linux-gnu/libc.so.6+0x92b7a) (BuildId: c495b62edadd6c356265942ec1282d98058a7b41)
       
      SUMMARY: MemorySanitizer: use-of-uninitialized-value /source/sql/sp_instr.h:279:9 in sp_lex_keeper::~sp_lex_keeper()
      Exiting
      

      Fix (in progress). just need to understand memroot comment above properly

      commit 7ce099e3034d9e9a820d0dc2f1c25e527c7efe14 (HEAD -> MDEV-40386)
      Author: Daniel Black <daniel@mariadb.org>
      Date:   Fri Aug 7 18:59:08 2026 +1000
       
          fix dtor ~sp_lex_keeper
       
      diff --git a/sql/sp_instr.h b/sql/sp_instr.h
      index 81385d7685a..471e9d0adfe 100644
      --- a/sql/sp_instr.h
      +++ b/sql/sp_instr.h
      @@ -274,7 +274,7 @@ class sp_lex_keeper final
           lex->sp_lex_in_use= true;
         }
       
      -  ~sp_lex_keeper()
      +  void destroy()
         {
           if (m_lex_resp)
           {
      @@ -286,6 +286,8 @@ class sp_lex_keeper final
             delete m_lex;
           }
         }
      +  ~sp_lex_keeper()
      +  { destroy(); }
       
         /**
           Prepare execution of instruction using LEX, if requested check whenever
      @@ -418,7 +420,7 @@ class sp_lex_instr : public sp_instr
               be freed, that would result in abnormal server termination)
             */
             free_items();
      -      m_lex_keeper.~sp_lex_keeper();
      +      m_lex_keeper.destroy();
       
             /*
               Ignore the OOM error explicitly since we are inside destructor
      

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              danblack Daniel Black
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.