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

Assertion in alloc_root fails when calling stored procedure with view

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 10.11, 11.4, 11.8, 12.1
    • 10.6, 10.11, 11.4, 11.8
    • None
    • None
    • Q4/2025 Server Maintenance

    Description

      The following script:

      create function f1() returns int
        return 42;
       
      create view v1 as 
        select f1();
       
      delimiter //;
       
      create procedure sp1()
      begin
        declare a int;
        set a = (select * from v1);
      end;
       
      create function f2() returns int
      begin
        call sp1();
        return 42;
      end;
       
      select f2();
      call sp1();
      //
      

      leads to failure of an assertion:

      DBUG_ASSERT((mem_root->flags & ROOT_FLAG_READ_ONLY) == 0);
      

      with following stack trace:

      Program terminated with signal SIGABRT, Aborted.
       
      #0  __pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:89
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:100
      #3  0x000055e23e94af71 in my_write_core (sig=6) at /src/mariadb/mysys/stacktrace.c:424
      #4  0x000055e23df59d4e in handle_fatal_signal (sig=6) at /src/mariadb/sql/signal_handler.cc:298
      #5  <signal handler called>
      #6  __pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44
      #7  __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:89
      #8  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:100
      #9  0x00007302f8c456de in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      #10 0x00007302f8c288cd in __GI_abort () at ./stdlib/abort.c:73
      #11 0x00007302f8c28830 in __assert_fail_base (fmt=<optimized out>, assertion=<optimized out>, file=<optimized out>, line=<optimized out>, function=<optimized out>) at ./assert/assert.c:118
      #12 0x000055e23e931d1c in alloc_root (mem_root=0x7302dc1ac418, length=480) at /src/mariadb/mysys/my_alloc.c:278
      #13 0x000055e23e1711d2 in Query_arena::alloc<Sroutine_hash_entry> (this=0x7302dc1ae0e8, size=1) at /src/mariadb/sql/sql_class.h:1318
      #14 0x000055e23e16dddb in sp_add_used_routine (prelocking_ctx=0x7302dc1b24e8, arena=0x7302dc1ae0e8, key=0x7302dc1b2230, handler=0x55e23f719c68 <sp_handler_function>, belong_to_view=0x7302dc1b4560) at /src/mariadb/sql/sp.cc:2413
      #15 0x000055e23e16ee2b in sp_update_stmt_used_routines (thd=0x7302dc000dc8, prelocking_ctx=0x7302dc1b24e8, src=0x7302dc1c0908, belong_to_view=0x7302dc1b4560) at /src/mariadb/sql/sp.cc:2848
      #16 0x000055e23da1b4f5 in DML_prelocking_strategy::handle_view (this=0x7302ed9c9af8, thd=0x7302dc000dc8, prelocking_ctx=0x7302dc1b24e8, table_list=0x7302dc1b4560, need_prelocking=0x7302ed9c98f0) at /src/mariadb/sql/sql_base.cc:5270
      #17 0x000055e23da1917a in open_and_process_table (thd=0x7302dc000dc8, tables=0x7302dc1b4560, counter=0x7302ed9c9a74, flags=0, prelocking_strategy=0x7302ed9c9af8, has_prelocking_list=false, ot_ctx=0x7302ed9c99e0) at /src/mariadb/sql/sql_base.cc:4293
      #18 0x000055e23da1a13f in open_tables (thd=0x7302dc000dc8, options=..., start=0x7302ed9c9a58, counter=0x7302ed9c9a74, flags=0, prelocking_strategy=0x7302ed9c9af8) at /src/mariadb/sql/sql_base.cc:4686
      #19 0x000055e23da1c16c in open_and_lock_tables (thd=0x7302dc000dc8, options=..., tables=0x7302dc1b4560, derived=true, flags=0, prelocking_strategy=0x7302ed9c9af8) at /src/mariadb/sql/sql_base.cc:5658
      #20 0x000055e23da2c83b in open_and_lock_tables (thd=0x7302dc000dc8, tables=0x7302dc1b4560, derived=true, flags=0) at /src/mariadb/sql/sql_base.h:535
      #21 0x000055e23ddeefed in sp_instr::exec_open_and_lock_tables (this=0x7302dc1ae0e8, thd=0x7302dc000dc8, tables=0x730Program terminated with signal SIGABRT, Aborted.
      2dc1b4560) at /src/mariadb/sql/sp_instr.cc:628
      #22 0x000055e23ddee54b in sp_lex_keeper::reset_lex_and_exec_core (this=0x7302dc1ae128, thd=0x7302dc000dc8, nextp=0x7302ed9c9d4c, open_tables=true, instr=0x7302dc1ae0e8, rerun_the_same_instr=false) at /src/mariadb/sql/sp_instr.cc:352
      #23 0x000055e23ddeec7b in sp_lex_keeper::validate_lex_and_exec_core (this=0x7302dc1ae128, thd=0x7302dc000dc8, nextp=0x7302ed9c9d4c, open_tables=true, instr=0x7302dc1ae0e8) at /src/mariadb/sql/sp_instr.cc:535
      #24 0x000055e23ddf0698 in sp_instr_set::execute (this=0x7302dc1ae0e8, thd=0x7302dc000dc8, nextp=0x7302ed9c9d4c) at /src/mariadb/sql/sp_instr.cc:1156
      #25 0x000055e23d9b8875 in sp_head::execute (this=0x7302dc1ac3d0, thd=0x7302dc000dc8, merge_da_on_success=true) at /src/mariadb/sql/sp_head.cc:1295
      #26 0x000055e23d9bb8df in sp_head::execute_procedure (this=0x7302dc1ac3d0, thd=0x7302dc000dc8, args=0x7302dc006358) at /src/mariadb/sql/sp_head.cc:2329
      #27 0x000055e23dae8224 in do_execute_sp (thd=0x7302dc000dc8, sp=0x7302dc1ac3d0) at /src/mariadb/sql/sql_parse.cc:3060
      #28 0x000055e23dae8ecb in Sql_cmd_call::execute (this=0x7302dc01fa08, thd=0x7302dc000dc8) at /src/mariadb/sql/sql_parse.cc:3283
      #29 0x000055e23daf2b96 in mysql_execute_command (thd=0x7302dc000dc8, is_called_from_prepared_stmt=false) at /src/mariadb/sql/sql_parse.cc:5861
      #30 0x000055e23daf915c in mysql_parse (thd=0x7302dc000dc8, rawbuf=0x7302dc01828d "call sp1()", length=10, parser_state=0x7302ed9cb2c0) at /src/mariadb/sql/sql_parse.cc:7891
      #31 0x000055e23dae4efd in dispatch_command (command=COM_QUERY, thd=0x7302dc000dc8, packet=0x7302dc00c149 "", packet_length=169, blocking=true) at /src/mariadb/sql/sql_parse.cc:1976
      #32 0x000055e23dae324c in do_command (thd=0x7302dc000dc8, blocking=true) at /src/mariadb/sql/sql_parse.cc:1416
      #33 0x000055e23dcfea6a in do_handle_one_connection (connect=0x55e250999f58, put_in_cache=true) at /src/mariadb/sql/sql_connect.cc:1414
      #34 0x000055e23dcfe7df in handle_one_connection (arg=0x55e250974f18) at /src/mariadb/sql/sql_connect.cc:1326
      #35 0x000055e23e2df44e in pfs_spawn_thread (arg=0x55e2508ffe08) at /src/mariadb/storage/perfschema/pfs.cc:2198
      #36 0x00007302f8ca2ef1 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:448
      #37 0x00007302f8d3445c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              raghunandan.bhat Raghunandan Bhat
              qobood Vasilii Lakhin
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.