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

Assertion `(mem_root->flags & 4) == 0' failed in alloc_root from parse_escaped_string on double PS EXECUTE

    XMLWordPrintable

Details

    Description

      Distinct from MDEV-34757 and not fixed by the patch thereof, with this testcase:

      CREATE VIEW c AS SELECT 1;
      PREPARE s FROM 'ALTER VIEW c AS SELECT 2';
      EXECUTE s;
      EXECUTE s;
      

      We see:

      CS 10.6.20 c630e23a186c7ecfe0afac21163cb4fa2cdc5f7a (Debug)

      mariadbd: /test/10.6_dbg/mysys/my_alloc.c:212: alloc_root: Assertion `(mem_root->flags & 4) == 0' failed.
      

      CS 10.6.20 c630e23a186c7ecfe0afac21163cb4fa2cdc5f7a (Debug)

      Core was generated by `/test/MD090924-mariadb-10.6.20-linux-x86_64-dbg/bin/mariadbd --no-defaults --ma'.
      Program terminated with signal SIGABRT, Aborted.
      Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 3934036)]
      (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  0x000014d63f44526e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x000014d63f4288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x000014d63f42881b in __assert_fail_base (fmt=0x14d63f5d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5632839cc63e "(mem_root->flags & 4) == 0", file=file@entry=0x563283961088 "/test/10.6_dbg/mysys/my_alloc.c", line=line@entry=212, function=function@entry=0x563283b3b040 <__PRETTY_FUNCTION__.0> "alloc_root") at ./assert/assert.c:94
      #6  0x000014d63f43b507 in __assert_fail (assertion=assertion@entry=0x5632839cc63e "(mem_root->flags & 4) == 0", file=file@entry=0x563283961088 "/test/10.6_dbg/mysys/my_alloc.c", line=line@entry=212, function=function@entry=0x563283b3b040 <__PRETTY_FUNCTION__.0> "alloc_root") at ./assert/assert.c:103
      #7  0x00005632835d58b0 in alloc_root (mem_root=0x14d5e401c238, length=16)at /test/10.6_dbg/mysys/my_alloc.c:212
      #8  0x0000563282a18417 in parse_escaped_string (ptr=ptr@entry=0x14d5e4024ea8 "select 2 AS `2`\nmd5=df27c95c6eba6092cfb7e3c801af0d09\nupdatable=0\nalgorithm=0\ndefiner_user=root\ndefiner_host=localhost\nsuid=1\nwith_check_option=0\ntimestamp=0001725831891150816\ncreate-version=2\nsource=S"..., end=end@entry=0x14d5e4024feb "", mem_root=mem_root@entry=0x14d5e401c238, str=0x14d63cdb1760)at /test/10.6_dbg/sql/parse_file.cc:656
      #9  0x0000563282a18745 in File_parser::parse (this=0x14d5e4024e70, base=base@entry=0x14d63cdb1510 "", mem_root=0x14d5e401c238, parameters=parameters@entry=0x5632840f2b40 <view_parameters>, required=required@entry=15, hook=0x5632840ddbd0 <file_parser_dummy_hook>)at /test/10.6_dbg/sql/parse_file.cc:855
      #10 0x0000563282c0a0b0 in mysql_make_view (thd=thd@entry=0x14d5e4000d58, share=share@entry=0x14d5e4026820, table=table@entry=0x14d63cdb1510, open_view_no_parse=open_view_no_parse@entry=true)at /test/10.6_dbg/sql/sql_view.cc:1385
      #11 0x0000563282a84783 in tdc_open_view (thd=thd@entry=0x14d5e4000d58, table_list=table_list@entry=0x14d63cdb1510, flags=flags@entry=16384)at /test/10.6_dbg/sql/sql_base.cc:3000
      #12 0x0000563282c08223 in fill_defined_view_parts (view=0x14d5e401efa0, thd=0x14d5e4000d58) at /test/10.6_dbg/sql/sql_view.cc:225
      #13 mysql_create_view (thd=thd@entry=0x14d5e4000d58, views=views@entry=0x14d5e401efa0, mode=VIEW_ALTER)at /test/10.6_dbg/sql/sql_view.cc:490
      #14 0x0000563282b07ce7 in mysql_execute_command (thd=0x14d5e4000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=true)at /test/10.6_dbg/sql/sql_parse.cc:5943
      #15 0x0000563282b20b40 in Prepared_statement::execute (this=this@entry=0x14d5e401bea8, expanded_query=expanded_query@entry=0x14d63cdb2cc0, open_cursor=open_cursor@entry=false)at /test/10.6_dbg/sql/sql_prepare.cc:5264
      #16 0x0000563282b20ee8 in Prepared_statement::execute_loop (this=this@entry=0x14d5e401bea8, expanded_query=expanded_query@entry=0x14d63cdb2cc0, open_cursor=open_cursor@entry=false, packet=packet@entry=0x0, packet_end=packet_end@entry=0x0) at /test/10.6_dbg/sql/sql_prepare.cc:4670
      #17 0x0000563282b213a3 in mysql_sql_stmt_execute (thd=thd@entry=0x14d5e4000d58)at /test/10.6_dbg/sql/sql_prepare.cc:3696
      #18 0x0000563282b02897 in mysql_execute_command (thd=thd@entry=0x14d5e4000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false)at /test/10.6_dbg/sql/sql_parse.cc:4004
      #19 0x0000563282b09d84 in mysql_parse (thd=thd@entry=0x14d5e4000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d63cdb32b0)at /test/10.6_dbg/sql/sql_parse.cc:8181
      #20 0x0000563282b0c21b in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d5e4000d58, packet=packet@entry=0x14d5e400b0c9 "EXECUTE s", packet_length=packet_length@entry=9, blocking=blocking@entry=true)at /test/10.6_dbg/sql/sql_class.h:242
      #21 0x0000563282b0e442 in do_command (thd=0x14d5e4000d58, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1410
      #22 0x0000563282c5b224 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x563286765c18, put_in_cache=put_in_cache@entry=true)at /test/10.6_dbg/sql/sql_connect.cc:1417
      #23 0x0000563282c5b524 in handle_one_connection (arg=arg@entry=0x563286765c18)at /test/10.6_dbg/sql/sql_connect.cc:1319
      #24 0x00005632830a92c4 in pfs_spawn_thread (arg=0x563286750818)at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
      #25 0x000014d63f49ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #26 0x000014d63f529c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Testcase is both CLI and MTR compatible.

      The commit that triggered this to be found:

      8ed3c375929b449ef8556cfa0c49a35707d59b84 is the first bad commit
      commit 8ed3c375929b449ef8556cfa0c49a35707d59b84
      Author: Oleksandr Byelkin <sanja@mariadb.com>
      Date:   Thu Jul 4 09:27:30 2024 +0200
       
          Make PROTECT_STATEMENT_MEMROOT default for version less then 11.2
       
       CMakeLists.txt | 11 +++++++++--
       1 file changed, 9 insertions(+), 2 deletions(-)
      

      Attachments

        Issue Links

          Activity

            People

              shulga Dmitry Shulga
              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.