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

Assertion `(mem_root->flags & 4) == 0' failed in void *alloc_root(MEM_ROOT *, size_t)

    XMLWordPrintable

Details

    Description

      The assertion is similar to MDEV-34895 but with a slightly different stack, since this issue related to sp parameter default value MDEV-10862, logged new issue

      --DELIMITER //
      CREATE PROCEDURE p(x INT DEFAULT (SELECT 1)) 
      BEGIN 
        SELECT x FROM DUAL;
      END;
      //
      --DELIMITER ;
      CALL p(1);
      CALL p();
      

      Leads to:

      CS 12.2.0 e02f4d7e311e214ea62ff2e59599849e229f4165 (Debug, Clang) Build 13/08/2025

      mariadbd: /test/12.1_dbg/mysys/my_alloc.c:278: void *alloc_root(MEM_ROOT *, size_t): Assertion `(mem_root->flags & 4) == 0' failed.
      

      CS 12.2.0 e02f4d7e311e214ea62ff2e59599849e229f4165 (Debug, Clang) Build 13/08/2025

      Core was generated by `/test/MD130825-mariadb-12.2.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'.
      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 164217)]
      (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  0x00007da1d144527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007da1d14288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007da1d142881b in __assert_fail_base (fmt=0x7da1d15d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5d6cc24a1dce "(mem_root->flags & 4) == 0", file=file@entry=0x5d6cc24a1c0e "/test/12.1_dbg/mysys/my_alloc.c", line=line@entry=278, function=function@entry=0x5d6cc24a1d7c "void *alloc_root(MEM_ROOT *, size_t)") at ./assert/assert.c:96
      #6  0x00007da1d143b517 in __assert_fail (assertion=0x5d6cc24a1dce "(mem_root->flags & 4) == 0", file=0x5d6cc24a1c0e "/test/12.1_dbg/mysys/my_alloc.c", line=278, function=0x5d6cc24a1d7c "void *alloc_root(MEM_ROOT *, size_t)")at ./assert/assert.c:105
      #7  0x00005d6cc2013eb5 in alloc_root (mem_root=0x7d82f00240d8, length=120)at /test/12.1_dbg/mysys/my_alloc.c:278
      #8  0x00005d6cc1295755 in Query_arena::calloc<Item*> (this=0x7d82f0025ef8, size=15) at /test/12.1_dbg/sql/sql_class.h:1327
      #9  0x00005d6cc126fed0 in st_select_lex::setup_ref_array (this=0x7d82f0024f30, thd=0x7d82f0000d58, order_group_num=0)at /test/12.1_dbg/sql/sql_lex.cc:3697
      #10 0x00005d6cc1324584 in JOIN::prepare (this=0x7d82f004f950, tables_init=0x0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7d82f0024f30, unit_arg=0x7d82f00254b0)at /test/12.1_dbg/sql/sql_select.cc:1582
      #11 0x00005d6cc183e9c5 in subselect_single_select_engine::prepare (this=0x7d82f0025eb8, thd=0x7d82f0000d58)at /test/12.1_dbg/sql/item_subselect.cc:3983
      #12 0x00005d6cc182e44a in Item_subselect::fix_fields (this=0x7d82f0025d10, thd_param=0x7d82f0000d58, ref=0x7d82f0025f90)at /test/12.1_dbg/sql/item_subselect.cc:294
      #13 0x00005d6cc1174a6a in Item::fix_fields_if_needed (this=0x7d82f0025d10, thd=0x7d82f0000d58, ref=0x7d82f0025f90) at /test/12.1_dbg/sql/item.h:1143
      #14 0x00005d6cc1191008 in THD::sp_fix_func_item (this=0x7d82f0000d58, it_addr=0x7d82f0025f90) at /test/12.1_dbg/sql/sp_head.cc:394
      #15 0x00005d6cc11910c1 in THD::sp_fix_func_item_for_assignment (this=0x7d82f0000d58, to=0x7d82f001bb30, it_addr=0x7d82f0025f90)at /test/12.1_dbg/sql/sp_head.cc:423
      #16 0x00005d6cc16af06e in Field::sp_prepare_and_store_item (this=0x7d82f001bb30, thd=0x7d82f0000d58, value=0x7d82f0025f90)at /test/12.1_dbg/sql/field.cc:1519
      #17 0x00005d6cc11911c8 in THD::sp_eval_expr (this=0x7d82f0000d58, result_field=0x7d82f001bb30, expr_item_ptr=0x7d82f0025f90)at /test/12.1_dbg/sql/sp_head.cc:448
      #18 0x00005d6cc11aa88e in sp_rcontext::set_variable (this=0x7d82f001af48, thd=0x7d82f0000d58, idx=0, value=0x7d82f0025f90)at /test/12.1_dbg/sql/sp_rcontext.cc:682
      #19 0x00005d6cc1578b12 in sp_instr_set::exec_core (this=0x7d82f0025ef8, thd=0x7d82f0000d58, nextp=0x7d9df0941748)at /test/12.1_dbg/sql/sp_instr.cc:1301
      #20 0x00005d6cc1575e66 in sp_lex_keeper::reset_lex_and_exec_core (this=0x7d82f0025f38, thd=0x7d82f0000d58, nextp=0x7d9df0941748, open_tables=true, instr=0x7d82f0025ef8, rerun_the_same_instr=false)at /test/12.1_dbg/sql/sp_instr.cc:418
      #21 0x00005d6cc15765ec in sp_lex_keeper::validate_lex_and_exec_core (this=0x7d82f0025f38, thd=0x7d82f0000d58, nextp=0x7d9df0941748, open_tables=true, instr=0x7d82f0025ef8)at /test/12.1_dbg/sql/sp_instr.cc:597
      #22 0x00005d6cc1578d11 in sp_instr_set_default_param::execute (this=0x7d82f0025ef8, thd=0x7d82f0000d58, nextp=0x7d9df0941748)at /test/12.1_dbg/sql/sp_instr.cc:1346
      #23 0x00005d6cc1193fac in sp_head::execute (this=0x7d82f0024090, thd=0x7d82f0000d58, merge_da_on_success=true)at /test/12.1_dbg/sql/sp_head.cc:1294
      #24 0x00005d6cc119693e in sp_head::execute_procedure (this=0x7d82f0024090, thd=0x7d82f0000d58, args=0x7d82f00060f8)at /test/12.1_dbg/sql/sp_head.cc:2328
      #25 0x00005d6cc12b9467 in do_execute_sp (thd=0x7d82f0000d58, sp=0x7d82f0024090)at /test/12.1_dbg/sql/sql_parse.cc:3056
      #26 0x00005d6cc12b8f94 in Sql_cmd_call::execute (this=0x7d82f0019f28, thd=0x7d82f0000d58) at /test/12.1_dbg/sql/sql_parse.cc:3279
      #27 0x00005d6cc12c530d in mysql_execute_command (thd=0x7d82f0000d58, is_called_from_prepared_stmt=false) at /test/12.1_dbg/sql/sql_parse.cc:5857
      #28 0x00005d6cc12b4664 in mysql_parse (thd=0x7d82f0000d58, rawbuf=0x7d82f0019e80 "CALL p4()", length=9, parser_state=0x7d9df0943a10)at /test/12.1_dbg/sql/sql_parse.cc:7883
      #29 0x00005d6cc12b1a38 in dispatch_command (command=COM_QUERY, thd=0x7d82f0000d58, packet=0x7d82f000b1f9 "CALL p4()", packet_length=9, blocking=true) at /test/12.1_dbg/sql/sql_parse.cc:1878
      #30 0x00005d6cc12b5213 in do_command (thd=0x7d82f0000d58, blocking=true)at /test/12.1_dbg/sql/sql_parse.cc:1417
      #31 0x00005d6cc14a24b9 in do_handle_one_connection (connect=0x5d6cce1373d8, put_in_cache=true) at /test/12.1_dbg/sql/sql_connect.cc:1414
      #32 0x00005d6cc14a225e in handle_one_connection (arg=0x5d6cce04f358)at /test/12.1_dbg/sql/sql_connect.cc:1326
      #33 0x00007da1d149caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #34 0x00007da1d1529c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.6   dbg  040825  317f099ca56130a14a45b7250996c207cc95d461  No bug found                  
      CS  10.6   opt  040825  317f099ca56130a14a45b7250996c207cc95d461  No bug found                            
      CS  10.11  dbg  130825  e46c9a01529687401b0f82b1427855535d38c0c0  No bug found                        
      CS  10.11  opt  130825  e46c9a01529687401b0f82b1427855535d38c0c0  No bug found                  
      CS  11.4   dbg  130825  03b31c0bd99390c1984f19a19f22dd6e77b7692e  No bug found                  
      CS  11.4   opt  130825  03b31c0bd99390c1984f19a19f22dd6e77b7692e  No bug found                  
      CS  11.8   dbg  130825  1a446ccc48528e88a3cd6cd1d1ec9e7492d342ca  (mem_root->flags & 4) == 0|SIGABRT|alloc_root|Query_arena::calloc<Item*>|st_select_lex::setup_ref_array|JOIN::prepare
      CS  11.8   opt  130825  1a446ccc48528e88a3cd6cd1d1ec9e7492d342ca  No bug found                  
      CS  12.1   dbg  130825  033471a367b4c60b7262e64f43f46b02e95b9d74  (mem_root->flags & 4) == 0|SIGABRT|alloc_root|Query_arena::calloc<Item*>|st_select_lex::setup_ref_array|JOIN::prepare
      CS  12.1   opt  130825  033471a367b4c60b7262e64f43f46b02e95b9d74  No bug found                  
      CS  12.2   dbg  130825  e02f4d7e311e214ea62ff2e59599849e229f4165  (mem_root->flags & 4) == 0|SIGABRT|alloc_root|Query_arena::calloc<Item*>|st_select_lex::setup_ref_array|JOIN::prepare
      CS  12.2   opt  130825  e02f4d7e311e214ea62ff2e59599849e229f4165  No bug found                  
      ES  10.5   dbg  040825  70586522eacf09d04d49962072e14325a75d8155  No bug found                  
      ES  10.5   opt  040825  70586522eacf09d04d49962072e14325a75d8155  No bug found                  
      ES  10.6   dbg  040825  9b794f34b48fb7eee490b6da44edc0f33a947447  No bug found                  
      ES  10.6   opt  040825  9b794f34b48fb7eee490b6da44edc0f33a947447  No bug found                  
      ES  11.4   dbg  040825  a1c03ccd54b582e75506687ee19b273ca897f261  No bug found                  
      ES  11.4   opt  040825  a1c03ccd54b582e75506687ee19b273ca897f261  No bug found                  
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.